If you haven't used MakeCode before, this guide is a good place to start.
Your Circuit Playground Express board comes ready to work with CircuitPython, and will show up as "CIRCUITPY" when connected to your computer. We'd like to make it work with MakeCode however, which is done by putting it into "bootloader mode". All that's required to do this is to connect the board to your computer with a micro USB cable and click the small reset button in the center of the board.
When the Circuit Playground Express is in Bootloader mode, all the LEDs will turn red briefly, then green. Verify your status LED is also pulsing red. Your computer should show a new removable drive called "CPLAYBOOT"
This will allow you to interact with the code used in this project.
Uploading code is easy, all you do is download the .uf2 file and drag 'n drop it onto the "CPLAYBOOT" drive.
The drive will automatically eject itself. (Your computer may give you a "failed to eject drive correctly" error, you can ignore this.)
This is the set of instructions that your Circuit Playground Express will follow.
It may look like a lot at first, but what we're doing are three things in sequence:
- Rotate servo quickly 100 degrees clockwise
- Play 'snake charmer' song
- Rotate servo slowly 100 degrees counter clockwise
It's always a good idea to do a dry run before putting everything together.
You can do this by connecting your servo motor to your Circuit Playground Express.
The servo has three wires, this is how they should connect:
Brown --> GND
Orange --> Vout
Yellow --> A2
When you press the "A" button you should see the servo rotating one way quickly, playing a short song, and then moving back slowly to its starting position.