Skip to content

Commit 687097e

Browse files
authored
Merge pull request #554 from isaacwellish/crickit-exhibit
Crickit exhibit guide edits
2 parents 3e8b5f9 + d55a516 commit 687097e

1 file changed

Lines changed: 8 additions & 11 deletions

File tree

Crickit_Exhibit/code.py

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,25 +52,22 @@
5252
# The following line sets up a NeoPixel strip on Crickit CPX pin A1
5353
pixels = neopixel.NeoPixel(board.A1, num_pixels, brightness=0.3, auto_write=False)
5454

55-
# NeoPixel function
55+
#sleep var for pushing both buttons
56+
SLEEP_DELAY = 0.1
5657

58+
# NeoPixel function
5759
def color_chase(color, wait):
5860
for i in range(num_pixels):
5961
pixels[i] = color
6062
time.sleep(wait)
6163
pixels.show()
6264
time.sleep(0.5)
6365

64-
# For signal control, we'll chat directly with seesaw, use 'ss' to shorted typing!
65-
ss = crickit.seesaw
6666
# potentiometer connected to signal #3
6767
pot = crickit.SIGNAL8
6868

6969
# initialize the light sensor on the CPX and the DC motor
70-
analogin = AnalogIn(board.LIGHT)
71-
72-
# initialize motor
73-
motor_1 = crickit.dc_motor_1
70+
light_in = AnalogIn(board.LIGHT)
7471

7572
while True:
7673

@@ -118,19 +115,19 @@ def color_chase(color, wait):
118115
# Light sensor + DC motor
119116

120117
# uncomment to see values of light
121-
# print(analogin.value)
118+
# print(light_in.value)
122119
# time.sleep(0.5)
123120

124121
# reads the on-board light sensor and graphs the brighness with NeoPixels
125122
# light value remaped to motor speed
126-
peak = map_range(analogin.value, 3000, 62000, 0, 1)
123+
peak = map_range(light_in.value, 3000, 62000, 0, 1)
127124

128125
# DC motor
129-
motor_1.throttle = peak # full speed forward
126+
crickit.dc_motor_1.throttle = peak # full speed forward
130127

131128
# hit both buttons to trigger noise
132129
if not ss.digital_read(BUTTON_1) and not ss.digital_read(BUTTON_2):
133130
print("Buttons 1 and 2 pressed")
134131
for f in (262, 294, 330, 349, 392, 440, 494, 523):
135132
tone(board.A0, f, 0.25)
136-
time.sleep(0.1)
133+
time.sleep(SLEEP_DELAY)

0 commit comments

Comments
 (0)