# Musical Walking Stick with Circuit Playground

## Overview

https://youtu.be/N4f4t2VU6TE

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

![](https://cdn-learn.adafruit.com/assets/assets/000/084/018/medium800thumb/circuitpython_Untitled.2019-11-11_16_44_55.jpg?1573509035)

## Parts
### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### Adafruit STEMMA Speaker - Plug and Play Audio Amplifier

[Adafruit STEMMA Speaker - Plug and Play Audio Amplifier](https://www.adafruit.com/product/3885)
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 Audio Amplifier**. Like the name implies, it's got a class D audio amplifier on board, and our...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3885)
[Related Guides to the Product](https://learn.adafruit.com/products/3885/guides)
![Top view of a black speaker breakout board connected to a round microcontroller via alligator clips. A music note animation emits from the speaker.](https://cdn-shop.adafruit.com/product-videos/640x480/3885-05.jpg)

### JST PH 2mm 3-pin Plug to Color Coded Alligator Clips Cable

[JST PH 2mm 3-pin Plug to Color Coded Alligator Clips Cable](https://www.adafruit.com/product/4030)
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 breakouts with 3-pin 'STEMMA' connectors on them such as the&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4030)
[Related Guides to the Product](https://learn.adafruit.com/products/4030/guides)
![Angled shot of JST PH 3-pin Plug to Color Coded Alligator Clips Cable.](https://cdn-shop.adafruit.com/640x480/4030-04.jpg)

### Copper Foil Tape with Conductive Adhesive - 6mm x 5 meters long

[Copper Foil Tape with Conductive Adhesive - 6mm x 5 meters long](https://www.adafruit.com/product/3483)
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 to it, and the tape itself can carry current just like a wire. On the back is an electrically conductive...

In Stock
[Buy Now](https://www.adafruit.com/product/3483)
[Related Guides to the Product](https://learn.adafruit.com/products/3483/guides)
![Roll of Copper Foil Tape with Conductive Adhesive - 6mm wide](https://cdn-shop.adafruit.com/640x480/3483-00.jpg)

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

### High-strength 'rare earth' magnet

[High-strength 'rare earth' magnet](https://www.adafruit.com/product/9)
Yow! These things are super powerful. .47" diameter and .18" thick discs. Great for use with your SpokePOV Kit. If you have an aluminium frame, use tape/foam sticky tape to attach it.

In Stock
[Buy Now](https://www.adafruit.com/product/9)
[Related Guides to the Product](https://learn.adafruit.com/products/9/guides)
![Angled shot of a High-strength 'rare earth' magnet.](https://cdn-shop.adafruit.com/640x480/9-01.jpg)

## Materials

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

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

![](https://cdn-learn.adafruit.com/assets/assets/000/083/768/medium800/circuitpython_IMG_8387.jpg?1573078751)

# Musical Walking Stick with Circuit Playground

## Circuit Diagram

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

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

![](https://cdn-learn.adafruit.com/assets/assets/000/083/638/medium800/circuitpython_adafruit_products_STEMMA_Speaker_CPX.png?1572993440)

![](https://cdn-learn.adafruit.com/assets/assets/000/083/637/medium800/circuitpython_Screen_Shot_2019-11-05_at_5.35.26_PM.png?1572993428)

# Musical Walking Stick with Circuit Playground

## Prepare Audio File

## 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/](http://soundbible.com/)&nbsp;or&nbsp;[https://freesound.org/](https://freesound.org/).&nbsp;

The [Imperial March theme](https://archive.org/details/StarWarsTheImperialMarchDarthVadersTheme) from Star Wars is a good example to start with (courtesy of archive.org).&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/083/592/medium800/circuitpython_blinka-Music.jpg?1572974704)

## Prepping your Audio

You will need to convert the files to the appropriate format for microcontroller use.&nbsp;[See this guide on how to convert audio files](https://learn.adafruit.com/microcontroller-compatible-audio-file-conversion/check-your-files).&nbsp;

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.

![circuitpython_Screen_Shot_2019-11-07_at_4.11.29_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/083/840/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.11.29_PM.png?1573161686)

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

![circuitpython_Screen_Shot_2019-11-07_at_4.11.36_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/083/841/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.11.36_PM.png?1573161743)

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

![circuitpython_Screen_Shot_2019-11-07_at_4.12.02_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/083/842/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.12.02_PM.png?1573161799)

Check that you're in 16-bit PCM format

![circuitpython_Screen_Shot_2019-11-07_at_4.12.10_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/083/844/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.12.10_PM.png?1573161911)

Ensure that your project rate is in 22050Hz

![circuitpython_Screen_Shot_2019-11-07_at_4.11.48_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/083/843/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.11.48_PM.png?1573161870)

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

![circuitpython_Screen_Shot_2019-11-07_at_4.12.21_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/083/845/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.12.21_PM.png?1573161937)

## No Mix & Match on mono and stereo files

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

If you're using multiple audio clips, make sure that they are **all Stereo** &nbsp;or&nbsp; **all Mono** &nbsp;-_no mix and match_!

# Musical Walking Stick with Circuit Playground

## CircuitPython Code

## 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,&nbsp;[this guide will get you started](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor).

If you haven't used Circuit Playground Express and CircuitPython together before, make sure you've updated it with the latest version of CircuitPython.&nbsp;[This guide will show you how](https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart).

![](https://cdn-learn.adafruit.com/assets/assets/000/083/593/medium800/makecode_circuitpython_circuit_playground_adafruit_blinka_computer.png?1572974743)

## 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&nbsp; **CIRCUITPY**. If you see a disk name&nbsp; **CPLAYBOOT** , try to press the reset button again. If the only drive name you get is&nbsp; **CPLAYBOOT** , CircuitPython may not be loaded on the board. You can load CircuitPython&nbsp;[per this guide](https://learn.adafruit.com/adafruit-circuit-playground-express).

Copy&nbsp; **code.py** &nbsp;from the link below and put it in&nbsp; **CIRCUITPY** &nbsp;root directory. You can work with this code in any text editing application, or open and save with&nbsp;[Mu](https://learn.adafruit.com/welcome-to-circuitpython/installing-mu-editor) 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`.

https://github.com/adafruit/Adafruit_Learning_System_Guides/blob/main/CPX_Walking_Stick/code.py

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

![circuitpython_Screen_Shot_2019-11-07_at_4.17.32_PM.png](https://cdn-learn.adafruit.com/assets/assets/000/084/020/medium640/circuitpython_Screen_Shot_2019-11-07_at_4.17.32_PM.png?1573509421)

Once the code is saved to&nbsp; **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.

![](https://cdn-learn.adafruit.com/assets/assets/000/083/957/medium800/circuitpython_Screen_Shot_2018-09-06_at_9.47.58_AM_copy.png?1573250135)

## 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.

![](https://cdn-learn.adafruit.com/assets/assets/000/083/927/medium800/circuitpython_IMG_8423.jpg?1573249966)

## 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&nbsp; **CIRCUITPY** &nbsp;when you connect the CPX to your computer. If it is showing up as&nbsp; **CPLAYBOOT** &nbsp;on your computer, you can&nbsp;[follow the steps in this guide](https://learn.adafruit.com/adafruit-circuit-playground-express/circuitpython-quickstart)&nbsp;to ensure CircuitPython is loaded and you see the&nbsp; **CIRCUITPY** &nbsp;drive.

&nbsp;

**Problem** : I can't hear any audio!

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

&nbsp;

**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 **&nbsp;** pack is set to "ON".

# Musical Walking Stick with Circuit Playground

## Laser Cutting (optional)

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/083/848/medium800/circuitpython_c2607fc18d88b1a18c7a5288576662fc.jpg?1573162315)

![](https://cdn-learn.adafruit.com/assets/assets/000/083/849/medium800/circuitpython_IMG_8401.jpg?1573165135)

# Musical Walking Stick with Circuit Playground

## Modifying a Cane

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

## Find a Cane

&nbsp;

Find a cane or walking stick you want to modify.

![circuitpython_IMG_8365.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/830/medium640/circuitpython_IMG_8365.jpg?1573155845)

## Attachment Port

&nbsp;

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

&nbsp;

Tape on a magnet with double-sided tape.

![circuitpython_IMG_8366.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/831/medium640/circuitpython_IMG_8366.jpg?1573156227)

![circuitpython_IMG_8368.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/832/medium640/circuitpython_IMG_8368.jpg?1573156264)

![circuitpython_IMG_8369.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/833/medium640/circuitpython_IMG_8369.jpg?1573156289)

## Faceplate

&nbsp;

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.

![circuitpython_IMG_8370.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/918/medium640/circuitpython_IMG_8370.jpg?1573249371)

![circuitpython_F1C87A32-8DA8-4D75-B76B-2756711677A5.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/920/medium640/circuitpython_F1C87A32-8DA8-4D75-B76B-2756711677A5.jpg?1573249460)

## Magnetize

&nbsp;

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

![circuitpython_IMG_8373.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/834/medium640/circuitpython_IMG_8373.jpg?1573156342)

![circuitpython_IMG_8374.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/835/medium640/circuitpython_IMG_8374.jpg?1573156383)

## Conductive Tape

&nbsp;

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

![circuitpython_IMG_8377.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/837/medium640/circuitpython_IMG_8377.jpg?1573156502)

## Attach Speaker

&nbsp;

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

![circuitpython_IMG_8376.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/838/medium640/circuitpython_IMG_8376.jpg?1573156599)

![circuitpython_IMG_8379.jpg](https://cdn-learn.adafruit.com/assets/assets/000/083/839/medium640/circuitpython_IMG_8379.jpg?1573156615)

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.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/083/836/medium800/circuitpython_IMG_8382.jpg?1573156437)

## 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!

![](https://cdn-learn.adafruit.com/assets/assets/000/084/016/medium800thumb/circuitpython_Untitled.2019-11-11_16_44_55.jpg?1573508976)


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### USB cable - USB A to Micro-B

[USB cable - USB A to Micro-B](https://www.adafruit.com/product/592)
This here is your standard A to micro-B USB cable, for USB 1.1 or 2.0. Perfect for connecting a PC to your Metro, Feather, Raspberry Pi or other dev-board or microcontroller

Approximately 3 feet / 1 meter long

Out of Stock
[Buy Now](https://www.adafruit.com/product/592)
[Related Guides to the Product](https://learn.adafruit.com/products/592/guides)
### Adafruit STEMMA Speaker - Plug and Play Audio Amplifier

[Adafruit STEMMA Speaker - Plug and Play Audio Amplifier](https://www.adafruit.com/product/3885)
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 Audio Amplifier**. Like the name implies, it's got a class D audio amplifier on board, and our...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3885)
[Related Guides to the Product](https://learn.adafruit.com/products/3885/guides)
### JST PH 2mm 3-pin Plug to Color Coded Alligator Clips Cable

[JST PH 2mm 3-pin Plug to Color Coded Alligator Clips Cable](https://www.adafruit.com/product/4030)
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 breakouts with 3-pin 'STEMMA' connectors on them such as the&nbsp;<a...></a...>

In Stock
[Buy Now](https://www.adafruit.com/product/4030)
[Related Guides to the Product](https://learn.adafruit.com/products/4030/guides)
### Copper Foil Tape with Conductive Adhesive - 6mm x 5 meters long

[Copper Foil Tape with Conductive Adhesive - 6mm x 5 meters long](https://www.adafruit.com/product/3483)
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 to it, and the tape itself can carry current just like a wire. On the back is an electrically conductive...

In Stock
[Buy Now](https://www.adafruit.com/product/3483)
[Related Guides to the Product](https://learn.adafruit.com/products/3483/guides)
### Conductive Nylon Fabric Tape - 5mm Wide x 10 meters long

[Conductive Nylon Fabric Tape - 5mm Wide x 10 meters long](https://www.adafruit.com/product/3961)
With our fun assortment of&nbsp;[conductive materials](https://www.adafruit.com/category/190),&nbsp;[cosplay](https://www.adafruit.com/index.php?main_page=category&cPath=290)&nbsp;and&nbsp;[wearables](https://www.adafruit.com/category/65)&nbsp;have never...

In Stock
[Buy Now](https://www.adafruit.com/product/3961)
[Related Guides to the Product](https://learn.adafruit.com/products/3961/guides)
### High-strength 'rare earth' magnet

[High-strength 'rare earth' magnet](https://www.adafruit.com/product/9)
Yow! These things are super powerful. .47" diameter and .18" thick discs. Great for use with your SpokePOV Kit. If you have an aluminium frame, use tape/foam sticky tape to attach it.

In Stock
[Buy Now](https://www.adafruit.com/product/9)
[Related Guides to the Product](https://learn.adafruit.com/products/9/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [Adafruit STEMMA Speaker](https://learn.adafruit.com/adafruit-stemma-speaker.md)
- [Sparkle Skirt Playground](https://learn.adafruit.com/sparkle-skirt-playground.md)
- [Motorized Grinch Fireplace](https://learn.adafruit.com/grinch-fireplace.md)
- [Remote Control Tree Ornament with Circuit Playground Express](https://learn.adafruit.com/remote-control-tree-ornament-with-circuit-playground-express.md)
- [CRICKIT WobblyBot](https://learn.adafruit.com/crickit-wobblybot.md)
- [Color Spinner Camera Ring Light ](https://learn.adafruit.com/camera-ring-light-with-cpx.md)
- [Make It Glow - Your First NeoPixel Project](https://learn.adafruit.com/make-it-glow-your-first-neopixel-project.md)
- [Paper Airplane Launcher](https://learn.adafruit.com/paper-airplane-launcher-with-crickit.md)
- [Circuit Playground Slouch Detector](https://learn.adafruit.com/circuit-playground-slouch-detector.md)
- [Thanksgiving Robotic Turkey Hand with Circuit Playground Express and Crickit](https://learn.adafruit.com/talking-turkey-hand.md)
- [Porting an Arduino library to CircuitPython: VL6180X Distance Sensor](https://learn.adafruit.com/porting-an-arduino-library-to-circuitpython-vl6180x-distance-sensor.md)
- [CircuitPython Sin Complicaciones para la Circuit Playground Express y la Bluefruit](https://learn.adafruit.com/circuitpython-sin-complicaciones-para-la-circuit-playground-express.md)
- [Sewable NeoPixels](https://learn.adafruit.com/flora-rgb-smart-pixels.md)
- [DAC Hacks for Circuit Playground Express & other ATSAMD21 Boards](https://learn.adafruit.com/circuit-playground-express-dac-hacks.md)
- [Bunny Ears with MakeCode](https://learn.adafruit.com/bunny-ears-with-makecode.md)
- [CircuitPython-Powered 3-minute Nightlight](https://learn.adafruit.com/circuitpython-powered-gemma-nightlight.md)
