Simplify per Ladyada
@@ -7,20 +7,19 @@ cpx.adjust_touch_threshold(600)
# Set the tap type: 1=single, 2=double
cpx.detect_taps = 1
-# NeoPixel settings
+# NeoPixel colors used
RED = (90, 0, 0)
BLACK = (0, 0, 0)
-step_col = [RED]
cpx.pixels.brightness = 0.1 # set brightness value
# The audio file assigned to the touchpad
-audio_file = ["imperial_march.wav"]
+audio_file = "imperial_march.wav"
-def play_it(index):
- cpx.pixels.fill(step_col[index]) # Light neopixels
- cpx.play_file(audio_file[index]) # play audio clip
- print("playing file " + audio_file[index])
+def play_it():
+ cpx.pixels.fill(RED) # Light neopixels
+ cpx.play_file(audio_file) # play audio clip
+ print("playing file ", audio_file)
cpx.pixels.fill(BLACK) # unlight lights
while True:
@@ -28,7 +27,7 @@ while True:
# trigger via touch or via single tap
if cpx.switch:
if cpx.touch_A1:
- play_it(0)
+ play_it()
else:
if cpx.tapped:
- play_it(0)
+ play_it()
\ No newline at end of file
