Skip to content

Commit 00e9721

Browse files
authored
Merge pull request #925 from adafruit/TheKitty-patch-110
Start a new repo for Dano's Walking Stick Guide
2 parents f51ace2 + beae645 commit 00e9721

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

CPX_Walking_Stick/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## The Musical Walking Stick tutorial on the Adafruit Learning System
2+
3+
The code in this repo accompanies the Adafruit tutorial
4+
Musical Walking Stick
5+
https://learn.adafruit.com/musical-cane/
6+
7+
The *appropriate code file file should be copied onto the **CIRCUITPY** flash drive as **code.py** that appears
8+
when you plug the CircuitPlayground Express into your computer via a known good USB cable.
9+
10+
If the only drive name you get is named **CPLAYBOOT**, CircuitPython may not be loaded
11+
on the board. You can load CircuitPython [per this guide](https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart). Then you should be able to see the **CIRCUITPY** drive when connected via USB.
12+
13+
CircuitPython resources may be found at https://CircuitPython.Org/
14+
15+
Learning Guide by Dano Wall
16+
Code written by Dano Wall and Anne Barela for Adafruit Industries, November 2019
17+
18+
MIT License, include all this text in any redistribution
19+
20+
Support Open Source development by buying your materials at [Adafruit.com](https://www.adafruit.com/).

CPX_Walking_Stick/code.py

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

0 commit comments

Comments
 (0)