We'll use Microsoft's drag-and-drop code editor to create the animations. MakeCode is an easy way to get up and running with the Circuit Playground Express. No prior coding knowledge is needed, and it's an easy way to experiment and learn to think like a coder.
Once your code is written, you'll simply plug your Circuit Playground Express into your computer via its USB port and click the "reset" button. All the lights will turn green and your Circuit Playground will appear as a drive on your computer called CPLAYBOOT. Drag your downloaded code onto this drive to program the Circuit Playground Express. Easy!
If you get a flash drive names CIRCUITPY, no worries, press the reset button twice and CPLAYBOOT should show up. It might take a time or two but it does work.
Head over to this Intro to MakeCode guide for more info on getting started with MakeCode.
If you want to skip right to the end and work backwards, here's the completed MakeCode project.
Code Design & User Interface
We have three different physical sets of lights:
- Circuit Playground's onboard lights, which will illuminate the egg
- Our 30/m NeoPixel strip, which will become the dragon's spines
- Our 4" pitch NeoPixel strand, which will become the eyes and the lights inside the mouth
We'll need to address all these separately in the code, and for the NeoPixel strand we'll need to get even trickier, since we want the eyes (pixels #0 and #1) to act differently than the mouth lights (pixels #2 and #3).
For my dragon, I want a white flickering, pulsing light inside the egg. I want the spines to have a flickering flame effect and the inside of the mouth to be the same, so they both appear to be lit by the dragon's internal fires. And my dragon will have beautiful whirling rainbow eyes.
We'll also code a capacitive touch on/off switch, wired to pin A4. Since our dragon is plugged into the wall, a software switch works fine - we can turn the lights on and off with code. If you're making a battery powered dragon, you may want to add a physical on/off switch, since the way we're doing it here leaves the Circuit Playground Express powered on all the time and that will drain your battery.