It's a good idea to test out your code before moving on to the final build. This page will lead you through a dry-run.
If you haven't used MakeCode before, this guide is a good place to start.
Getting into Bootloader Mode
To make your board work with MakeCode we need to put 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.
Now we're ready for MakeCode!
Click this link or the button below to enter the portal to interact with the code for this project.
How to Upload the Code
To upload code, connect you Circuit Playground Express to your computer using the micro USB cable, click the Download button to download the .uf2 file to your computer, 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.) The code is now on your Circuit Playground Express and ready to run!
Testing the Code
This sketch in MakeCode uses the light sensor on Circuit Playground Express to control the motors.
on start block we can see three startup commands. The threshold for what is considered a "loud sound" is lowered to 10, the volume level is set to almost full volume, and the servo motor is initialized, so it will always start in the same position.
In the three
forever blocks, there are
if / else statements, which gives the following instructions:
sound level goes above the specified value, move the servo back and forth 4 times.
light level goes below the specified value (in this case,
50), run the DC motor.
acceleration strength goes above
1022, turn all neopixels white.
Once powered on, you should be able to test your circuit by snapping or clapping. In response, the servo arm should twitch back and forth.
The light sensor is used to detect when the light level falls below a specified value. When you cast a shadow over the board you should see the DC motor start spinning in response.
Finally, your board should now be sensitive to being moved, even small vibrations. You can test this by tapping your board or thumping the table it's on, and the NeoPixels LEDs should flash white in response.
If you'd like to play with this code, click Edit and a new window will open in which you can create your own version.
When you want to try out your new code, connect Circuit Playground Express to your computer with a micro USB cable, download your adapted code, and drag the new .uf2 file onto your CPLAYBOOTdrive.
Problem: My motors aren't working!
Solution: Make sure that the small slide switch on the CRICKIT is set to "ON".
Problem: My motors still aren't moving!
Solution: Make sure you've updated your Circuit Playground Express with the latest special 'seesaw' version of the CPX firmware. This guide will show you how.
Problem: My Circuit Playground Express doesn't show up as CPLAYBOOT!
Solution: Your Circuit Playground Express board comes ready to work with CircuitPython, and will show up as a flash drive named CIRCUITPY the first time it's connected to your computer. To switch over to work with MakeCode, connect the board to your computer with a micro USB cable and click the small reset button in the center of the board.
When Circuit Playground Express is in Bootloader mode, all the LEDs will flash red briefly, then turn green. Your computer should now show removable drive called CPLAYBOOT. Now you can copy the MakeCode file to the CPLAYBOOT flash drive.