Take any short clip of music and have it automatically start playing as soon as you pick up your cane and start walking. A few lines of code add illumination to a custom faceplate of your design, making the walking stick a gleaming beacon as well as a magically musical object.

In this project, a friend with a cane wanted to turn it into a Darth Vader cosplay, complete with Empire signet and the imperial march!

We'll use CircuitPython's easy capacitive touch and audio playback to make it happen

Parts

Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
$24.95
In Stock
Hey, have you heard the good news? With Adafruit STEMMA boards you can easily and safely plug sensors and devices together, like this Adafruit STEMMA Speaker - Plug and Play...
$5.95
In Stock
This cable will let you turn a JST PH 3-pin cable port into 3 individual wires with grippy mini alligator clips. We're carrying these to match up with any of our boards or...
$1.95
In Stock
Copper tape can be an interesting addition to your toolbox. The tape itself is made of thin pure copper so it's extremely flexible and can take on nearly any shape. You can solder...
$4.95
In Stock

You'll need two decently strong magnets. These are very strongly attracted.

Yow! These things are super powerful. 1/2" diameter, 3/16" thick discs, south side is marked with a red line. Great for use with your SpokePOV Kit. If you have an aluminium...
$2.50
In Stock

Materials

In addition to the above electronics, for this project you will need:

  • A cane or walking stick 
  • Double sided foam tape
  • Scissors
  • Zip ties or rubber bands
  • Access to a laser cutter (optional)

The circuit for this project connects the Circuit Playground Express board to the Stemma speaker using alligator clips.

The alligator clips connect to Vout, GND and the A0 (for audio output) on the CPX board.

Choose your own

It's time to add some sound effects to your walking stick! You can adapt existing audio files from your computer for use in this project, or audio clips and sound effects can be downloaded from sites like http://soundbible.com/ or https://freesound.org/

The Imperial March theme from Star Wars is a good example to start with (courtesy of archive.org). 

Prepping your Audio

You will need to convert the files to the appropriate format for microcontroller use. See this guide on how to convert audio files

Your audio file must be named something like file_name.wav, make sure that it matches what's written in the code.

Trimming and Exporting your Audio

Follow the steps below to select a portion of any audio file you want to play.

Import your audio file of choice into Audacity.

Click and drag to select the portion of the audio file you want to select.

To crop this selection, navigate to Edit -> Remove Special -> Trim Audio

If your audio has two channels, use the "Mix Stereo Down to Mono" function to compress it down into a single track.

Check that you're in 16-bit PCM format

Ensure that your project rate is in 22050Hz

Export as WAV, and you're ready to rock!

No Mix & Match on mono and stereo files

Make sure your audio file is exported as 16-bit PCM WAV at 22,050 Hz.

If you're using multiple audio clips, make sure that they are all Stereo or all Mono -no mix and match!

Getting Familiar

CircuitPython is a programming language based on Python, one of the fastest growing programming languages in the world. It is specifically designed to simplify experimenting and learning to code on low-cost microcontroller boards.

CircuitPython is easiest to use within the Mu Editor. If you haven't previously used Mu, this guide will get you started.

If you haven't used Circuit Playground Express and CircuitPython together before, make sure you've updated it with the latest version of CircuitPython. This guide will show you how.

The Code

Plug your Circuit Playground Express into your computer (mac/PC/Linux) via a known good USB A to micro-B cable. Your board should appear to the computer as a flash disk drive named CIRCUITPY. If you see a disk name CPLAYBOOT, try to press the reset button again. If the only drive name you get is CPLAYBOOT, CircuitPython may not be loaded on the board. You can load CircuitPython per this guide.

Copy code.py from the link below and put it in CIRCUITPY root directory. You can work with this code in any text editing application, or open and save with Mu if you prefer. You will need to ensure the wav file you have prepared is coded into the code, i.e. if your wav file is trumpet.wav, then in the code replace imperial_march.wav with trumpet.wav.

# Talking Cane
# for Adafruit Circuit Playground Express with CircuitPython
from adafruit_circuitplayground.express import cpx

# Change this number to adjust touch sensitivity threshold
cpx.adjust_touch_threshold(600)
# Set the tap type: 1=single, 2=double
cpx.detect_taps = 1

# NeoPixel colors used
RED = (90, 0, 0)
BLACK = (0, 0, 0)

cpx.pixels.brightness = 0.1  # set brightness value

# The audio file assigned to the touchpad
audio_file = "imperial_march.wav"

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:
    # playback mode. Use the slide switch to change between
    #   trigger via touch or via single tap
    if cpx.switch:
        if cpx.touch_A1:
            play_it()
    else:
        if cpx.tapped:
            play_it()

No libraries are need for this code to run, just drag and drop your WAV file of choice onto your CIRCUITPY drive.

Once the code is saved to CIRCUITPY and your audio file is on there too, you should be able to test that it plays by touching the capacitive pad or shaking the board and the miniature speaker on the STEMMA board will play your chosen audio.

Change Functions

By changing the position of the slide switch on the board, you can alter the function, making it sensitive to impacts instead of touch sensitive.

The code is set up so that it's easy to add multiple audio files to the project, which can play in random order or be tied to specific inputs from Circuit Playground Express.

Troubleshooting

Problem: My Circuit Playground Express isn't recognized by Mu!

Solution: Make sure your board is set up with CircuitPython, which has the Circuit Playground Express show up as a flash drive named CIRCUITPY when you connect the CPX to your computer. If it is showing up as CPLAYBOOT on your computer, you can follow the steps in this guide to ensure CircuitPython is loaded and you see the CIRCUITPY drive.

 

Problem: I can't hear any audio!

Solution: Check that your audio file name matches what is written in the code. 

 

Problem: I STILL can't hear any audio!

Solution: If you're using a battery pack, check that your Circuit Playground Express is connected and the slide switch on the pack is set to "ON".

A quick search for the Imperial Crest returns an image that can be easily engraved onto a piece of acrylic.

All Circuit Playground boards are 2.1 inches in diameter. Scaling the image to this size we are able to create a simple yet effective faceplate for the CPX board.

The final step of this process is to put it all together to make a walking stick come alive.

Find a Cane

 

Find a cane or walking stick you want to modify.

Attachment Port

 

Find a spot on the cane where you want to mount the Circuit Playground Express.

 

Tape on a magnet with double-sided tape.

Faceplate

 

If you'd like to attach something to the front, some small squares of foam tape work well to hold any faceplate on the CPX board.

Magnetize

 

Use another small magnet to make the board easy to attach and remove from the cane.

Conductive Tape

 

Stick copper tape to handle. Wrap it in such as way that it is easy to reach when you're using the cane.

Attach Speaker

 

Two zip ties can hold the speaker and battery to the cane.

When finished, your cane or walking stick should now have a formidable appearance and work to light the path in front of you with its gleaming neopixels. 

Use

With the slide switch in one position, the cane will play the wav file when you touch the copper tape.

Flip the slide switch and the file will play every time the accelerometer on the Circuit Playground Express detects a single tap like when the cane hits the floor.

The Circuit Playground Express also detects double taps! Double might be good for occasional wav file playing (like the pape). Just change the line cpx.detect_taps = 1 to cpx.detect_taps = 2.

Walk with style with your new musical cane!

This guide was first published on Nov 13, 2019. It was last updated on Nov 13, 2019.