If you'd like to learn more about MakeCode, this guide is a good place to start.
To upload code, connect you Circuit Playground Express to your computer using a micro USB cable and press the small reset button in the center of the board. All the LEDs will flash red briefly, then turn green. Your computer should now show removable drive called CPLAYBOOT.
Click the Download button to download the .uf2 file to your computer, and drag 'n drop that .UF2 file onto the CPLAYBOOT drive in your computer's file explorer or finder.
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!
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.
First, in the
on_start loop, we tell Circuit Playground Express to move the servo motor connected to pin A1 to 90°, i.e. the middle of its range. This guarantees that the rudder always starts from the same position, point straight back from the boat.
Over in the
on free fall loop, we tell the servo to move back and forth 20 times with
100ms (1/10th of a second) pauses between each movement. At the end of these 20 flaps the servo returns back to its starting position of 90°.
Now is a good time to test your boat out in a body of water. If you have different types of rudders to test this is also a fun time to see which will make the boat go faster.
Some questions to ask:
Does it move the boat faster or slower? What could be changed about the rudder to make it more effective at pushing the boat through the water?
Problem: My motor won't move!
Solution: Make sure that your Circuit Playground Express is connected to a power source (anywhere between 3V-5V is safe). If you're using a AAAx3 battery pack, check that the switch on the battery pack is set to "ON".
Problem: My Circuit Playground Express doesn't show up as CPLAYBOOT
- Be sure you have a Circuit Playground Express. The Classic will not work with MakeCode.
- Some USB cables are "charge-only" and won't pass data. Try using a different USB cable and try using a different USB port on your computer.
- With the Circuit Playground plugged into your computer with a micro USB cable, click the small reset button in the center of the board. The lights should all turn green. If they don't, try double-clicking the reset button.
If things still aren't working, head over to the Intro to Circuit Playground Express guide for more suggestions.