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
show animation for 500 ms into your workspace, and drop it inside the
forever loop that's already on the desktop. (If it's not there, you can find it under the LOOPS tab).
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
on button A click from the INPUT tab into the workspace. Anything inside this block will run whenever the A button (or whatever input you choose) is clicked.
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.
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
play melody block will play up to 8 notes, but you can copy and paste the block inside the
on button A loop until you have as many lines as you'd like.
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.