File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-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
+ RED = (90 , 0 , 0 )
12
+ BLACK = (0 , 0 , 0 )
13
+ step_col = [RED ]
14
+
15
+ cpx .pixels .brightness = 0.1 # set brightness value
16
+
17
+ # The audio file assigned to the touchpad
18
+ audio_file = ["imperial_march.wav" ]
19
+
20
+ def play_it (index ):
21
+ cpx .pixels .fill (step_col [index ]) # Light neopixels
22
+ cpx .play_file (audio_file [index ]) # play audio clip
23
+ print ("playing file " + audio_file [index ])
24
+ cpx .pixels .fill (BLACK ) # unlight lights
25
+
26
+ while True :
27
+ # playback mode. Use the slide switch to change between
28
+ # trigger via touch or via single tap
29
+ if cpx .switch :
30
+ if cpx .touch_A1 :
31
+ play_it (0 )
32
+ else :
33
+ if cpx .tapped :
34
+ play_it (0 )
35
+
You can’t perform that action at this time.
0 commit comments