This DIY boat project is a great way to dip one's toes into coding. 

A one-quart milk carton is the perfect size for a boat that will easily contain all the electronics you want to add while still a convenient size for playing in a bathtub. 

This project will take you through the build process and demonstrate how to use MakeCode to control the boat in a variety of ways.

Adafruit Electronics

A Black woman's manicured hand holds a round microcontroller with lit up LEDs.
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and...
In Stock
Micro servo with three pin cable
Tiny little servo can rotate approximately 180 degrees (90 in each direction) and works just like the standard kinds you're used to but smaller. You can use any servo...
In Stock
Group of Small Alligator Clip to Male Jumper Wires
When working with unusual non-header-friendly surfaces, these handy cables will be your best friends! No longer will you have long, cumbersome strands of alligator clips. These...
In Stock
Top view shot of JST 2-pin Extension Cable with On/Off Switch.
By popular request - we now have a way you can turn on-and-off Lithium Polymer batteries without unplugging them.This PH2 Female/Male JST 2-pin Extension...
In Stock
Slim Lithium Ion Polymer Battery 3.7v 400mAh with JST 2-PH connector and short cable
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This...
In Stock
Front angled shot of 3 x AAA battery holder with on-off switch and 2-pin JST PH connector.
This battery holder connects 3 AAA batteries together in series for powering all kinds of projects. We spec'd these out because the box is slim, and 3 AAA's add up to about...
In Stock
Angled shot of 3 PKcell AAA batteries.
Battery power for your portable project! These batteries are good quality at a good price, and work fantastic with any of the kits or projects in the shop that use AAA's. This is a...
In Stock

Other Materials

For this project you will need:

  • Empty quart-sized milk carton
  • Scissors and/or box cutter
  • Double sided tape
  • Scrap corrugated cardboard
  • Clear masking tape

The circuit for this project is quite simple, just connect the Vout pad on Circuit Playground Express (CPX) to the servo's red wire, the A1 pad to the yellow wire, and the GND pad to the brown wire. 

The alligator clip-to-male jumper wire connectors are great for connecting servo motors to CPX.

Powering your Boat

Circuit Playground Express can use a variety of power sources, anywhere between 3V-5V is safe. These compact 400mAh lithium ion polymer batteries are excellent for powering small projects like this. 

A set of 3 AAA batteries also provides ample power, if that option is more convenient. If you're using a AAAx3 battery pack, check that the switch on the battery pack is set to "ON" when you want to power the boat.

Simple Cardboard Boat


Find an empty milk carton or similar container. Rinse out thoroughly.


Use a hobby knife to carefully cut around the carton.

Please be careful in using sharp objects to cut items and adults should assist younger makers.

Cut a small notch in the back of the boat, this will provide space for the rudder to project out from the back of the boat.

The Rudder

There is a lot of experimenting to be had in the rudder department. 

These two examples demonstrate how to create a simple and straightforward rudder, and a more complex, bio-inspired cardboard & tape rudder to power your boat. 

Comparing different types of rudders can be lots of fun, experiment with these two types or come up with your own versions to see what makes your boat go fastest!

Simple Rudder


Straighten out a paper clip.

Bend it in half, then introduce two small 90° bends at the tips. 

Stick the ends of the paper clip into the servo arm, press arm onto servo horn. 

Cut a flap out of scrap milk carton and hot glue this to the paper clip.

Fish-Tail Rudder


Cut three square pieces of cardboard.

Lay these out on the piece of tape, leaving a small gap (~1/8", ~3mm) between them.

Place another piece of tape over the top and press together.

Test out your rudder to see how it moves!

Attach Rudder


Attach the rudder of your choice to the servo motor.

Water Resistance


Before setting sail it's a good idea to place your electronics in a plastic bag for an extra layer of water protection.

Getting Familiar

The code for this project was created using Microsoft MakeCode for Adafruit, a web-based code editor. MakeCode provides a block editor, similar to Scratch or, and also a JavaScript editor for more advanced users.

If you'd like to learn more about MakeCode, this guide is a good place to start.

How to Upload Code

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.

What is this code doing?

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°. 

Go Swimming! 

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.

Rather than dropping the boat to trigger the servo to start moving, an extra Circuit Playground Express can be used as a remote controller to tell it when to move.

This example uses the IR transmitter and receiver to send and receive an infrared signal.

In the image below, the transmitter is the big clear LED on the left, and the darker receiver LED on the right will receive the 38KHz signals and demodulate them for you.

Code for the Boat

In this MakeCode example, the directions telling the rudder to flap are moved into a function which can be called when either the boat is dropped OR when CPX receives an infrared signal.

Code for the Remote Controller

The second Circuit Playground Express will be used as the remote control. This needs only a simple function in MakeCode, telling it to send an infrared signal when a button is pressed. 

Infrared light is invisible to the human eye, so this function includes instructions to briefly flash the NeoPixels on the board white when it sends the signal, allowing the user to see that CPX has properly received and executed its instructions. 

Test out your remote control on your boat. Pressing the A button should trigger your boat to start swimming!

Luckily, infrared light isn't impeded by a layer of plastic, so you can keep your battery and electronics safe in a clear plastic bag. But keep in mind, the two boards must have a visible line of sight to each other, and be careful to avoid accidentally covering the IR component on the board with your fingers. 

This guide was first published on Mar 15, 2019. It was last updated on Mar 15, 2019.