User Manual

# Maps a number from one range to another.
def map_range(x, in_min, in_max, out_min, out_max):
mapped = (x-in_min) * (out_max - out_min) / (in_max-in_min) + out_min
if out_min <= out_max:
return max(min(mapped, out_max), out_min)
return min(max(mapped, out_max), out_min)
# Wait before starting up
time.sleep(3)
play_file("i-gotta-have-more-cowbell.wav")
# a pause between audio clips
time.sleep(1)
play_file("only-prescription-more-cowbell.wav")
while seesaw.digital_read(SWITCH):
pass
print("Ready for playing audio")
time.sleep(1)
f = open("fear11.wav", "rb")
wav = audioio.WaveFile(f)
a.play(wav)
while True:
if seesaw.digital_read(SWITCH):
break # time to bail!
pot = seesaw.analog_read(MORECOW)
print(pot)
eyecolor = (int(map_range(pot, 0, 1023, 255, 0)), int(map_range(pot, 0, 1023, 0, 255)), 0)
pixels[8] = eyecolor
pixels[7] = eyecolor
if buttonb.value:
fog_on.duty_cycle = 65535
else:
fog_on.duty_cycle = 0
if buttona.value:
fog_off.duty_cycle = 65535
else:
fog_off.duty_cycle = 0
if pot < 200: # wait for a bit before we start
continue
delay = map_range(pot, 200, 1023, 1.0, 0.1)
servos[0].angle = BELL_END
time.sleep(0.1)
servos[0].angle = BELL_START
time.sleep(delay)
a.stop()
f.close()
# Fog machine test
fog_off.duty_cycle = 65535
fog_on.duty_cycle = 0
time.sleep(0.1)
fog_off.duty_cycle = 0
© Adafruit Industries
https://learn.adafruit.com/adafruit-crickit-creative-robotic-interactive-
construction-kit
Page 165 of 201