Skip to content

Commit d0747e4

Browse files
authored
Add files via upload
1 parent 6d99c99 commit d0747e4

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

CPX_Walking_Stick/code.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+

0 commit comments

Comments
 (0)