The Circuit Playground Express can be programmed a number of ways: it will run Arduino code, CircuitPython, or you can program it with MakeCode.
This means you can drag and drop light animations and functionality using the Circuit Playground Express' onboard sensors without ever writing a single line of code. Just snap the blocks together and watch your lights dance.
For this project, I used the Circuit Playground's onboard lights to run a pretty rainbow color animation and the onboard speaker to play Jingle Bells every time a button is pressed. The colors and sounds are easy to customize to play your favorite Holiday song.
Go to https://makecode.adafruit.com/ and select "New Project".
Give it a name. I called mine "Unicorn Stocking."
First we'll add the light animation. Click the LIGHT tab and drag an instance of
Anything placed inside this block will run over and over, forever.
Check out the simulator on the left side of the screen. Are the lights animating rainbow? That means you've done it right. This is easy.
Now we'll add music that plays when the button on the face of the Circuit Playground is pressed. The buttons or sensors are accessed under the INPUT tab.
Drag an instance of
While you're here, take a look under the dropdowns to see all the different input options you've got. I kept it simple using button A, but you can trigger your code with any of these inputs just by selecting them.
Choose the MUSIC tab and drag an instance of
Click the music note and the editor window will appear. Choose your first melody note from the first column, the second from the second column, etc. For a rest note, leave the column blank.
Jingle Bells starts on the third of its key, so it will work out best if you voice it as shown. Each
Click the A button in the simulator to hear your melody played back. I found 120 bpm to be a bit slow and dirge-like, so I sped up my tempo to 200 bpm, which is a bit more cheerful.
There are more tools available under the MUSIC tab that will allow you more control -- play around with them until you're happy with your composition.
- Plug your Circuit Playground Express into your computer with a USB cable.
- Click the reset button.
- Green lights will appear on the Circuit Playground's face and it will appear in your list of devices, called CPLAYBOOT.
If you don't see this or get a drive called CIRCUITPY, try double-clicking the reset button instead of single-clicking to get to a drive named CPLAYBOOT. Putting code on a CIRCUITPY drive will not program it.
Click the pink Download button on your MakeCode screen and the code you just made will download to your computer. Drag it onto the CPLAYBOOT device.
If all goes well, you will see a pretty rainbow animation. Click the A button and the Circuit Playground's tiny onboard speaker will play Jingle Bells. Hooray!
Here's the completed project that you can play with directly.