File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change 1+ # Talking Cane
2+ # for Adafruit Circuit Playground Express with CircuitPython
3+ from adafruit_circuitplayground .express import cpx
4+
5+ # Change this number to adjust touch sensitivity threshold
6+ cpx .adjust_touch_threshold (600 )
7+ # Set the tap type: 1=single, 2=double
8+ cpx .detect_taps = 1
9+
10+ # NeoPixel settings
11+ step_col = [RED ]
12+ RED = (90 , 0 , 0 )
13+ BLACK = (0 , 0 , 0 )
14+ cpx .pixels .brightness = 0.1 # set brightness value
15+
16+ # The audio file assigned to the touchpad
17+ audio_file = ["imperial_march.wav" ]
18+
19+ def play_it (index ):
20+ cpx .pixels .fill (step_col [index ]) # Light neopixels
21+ cpx .play_file (audio_file [index ]) # play audio clip
22+ print ("playing file " + audio_file [index ])
23+ cpx .pixels .fill (BLACK ) # unlight lights
24+
25+ while True :
26+ # playback mode. Use the slide switch to change between
27+ # trigger via touch or via single tap
28+ if cpx .switch :
29+ if cpx .touch_A1 :
30+ play_it (0 )
31+ else
32+ if cpx .tapped :
33+ play_it (0 )
34+
You can’t perform that action at this time.
0 commit comments