# Buttermilk Boat with Circuit Playground Express

## Overview

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

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.&nbsp;

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

![](https://cdn-learn.adafruit.com/assets/assets/000/072/495/medium800thumb/makecode_IMG_2513.2019-03-08_18_32_47.jpg?1552087987)

## Adafruit Electronics
### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
![A Black woman's manicured hand holds a round microcontroller with lit up LEDs.](https://cdn-shop.adafruit.com/640x480/3333-05.jpg)

### Micro servo

[Micro servo](https://www.adafruit.com/product/169)
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 code, hardware, or library to control these servos. Good for beginners who want to make stuff move without...

Out of Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
![Micro servo with three pin cable](https://cdn-shop.adafruit.com/640x480/169-06.jpg)

### JST 2-pin Extension Cable with On/Off Switch - JST PH2

[JST 2-pin Extension Cable with On/Off Switch - JST PH2](https://www.adafruit.com/product/3064)
By popular request - we now have a way you can turn on-and-off Lithium Polymer batteries without unplugging them.

This **PH2 Female/Male&nbsp;JST 2-pin Extension Cable&nbsp;** comes with an in-line **Switch** - click once to turn on, click again to turn off....

In Stock
[Buy Now](https://www.adafruit.com/product/3064)
[Related Guides to the Product](https://learn.adafruit.com/products/3064/guides)
![Top view shot of JST 2-pin Extension Cable with On/Off Switch.](https://cdn-shop.adafruit.com/640x480/3064-02.jpg)

### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
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 battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
![Slim Lithium Ion Polymer Battery 3.7v 400mAh with JST 2-PH connector and short cable](https://cdn-shop.adafruit.com/640x480/3898-05.jpg)

### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
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 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
![Front angled shot of 3 x AAA battery holder with on-off switch and 2-pin JST PH connector.](https://cdn-shop.adafruit.com/640x480/727-07.jpg)

### Alkaline AAA batteries - 3 pack

[Alkaline AAA batteries - 3 pack](https://www.adafruit.com/product/3520)
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 pack of **3 AAA batteries**.  
  
These batteries are Alkaline (MnO2) chemistry, with a...

In Stock
[Buy Now](https://www.adafruit.com/product/3520)
[Related Guides to the Product](https://learn.adafruit.com/products/3520/guides)
![Angled shot of 3 PKcell AAA batteries. ](https://cdn-shop.adafruit.com/640x480/3520-00.jpg)

## Other Materials

For this project you will need:

- Empty quart-sized milk carton
- Scissors and/or box cutter
- [Double sided tape](https://www.amazon.com/dp/B003W0R4PE/ref=cm_sw_r_tw_dp_U_x_Y2SGBb4DV10TX)
- Scrap corrugated cardboard
- Clear masking tape

# Buttermilk Boat with Circuit Playground Express

## The Circuit

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.&nbsp;

The&nbsp;[alligator clip-to-male jumper wire](https://www.adafruit.com/product/3448) connectors are great for connecting servo motors to CPX.

![](https://cdn-learn.adafruit.com/assets/assets/000/073/142/medium800/makecode_CPX_servo_jumper.png?1552662024)

## 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](https://www.adafruit.com/product/3898) are excellent for powering small projects like this.&nbsp;

A set of [3 AAA batteries](https://www.adafruit.com/product/3520) also provides ample power, if that option is more convenient. If you're using a [AAAx3 battery pack](https://www.adafruit.com/product/727), check that the switch on the **&nbsp;** battery pack is set to "ON" when you want to power the boat.

![](https://cdn-learn.adafruit.com/assets/assets/000/072/646/medium800/makecode_IMG_2313.jpg?1552431677)

# Buttermilk Boat with Circuit Playground Express

## Cardboard Boat

## Simple Cardboard Boat

&nbsp;

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

&nbsp;

Use a hobby knife to carefully cut around the carton.

![makecode_IMG_2472_copy.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/455/medium640/makecode_IMG_2472_copy.jpg?1552074889)

![makecode_IMG_1248.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/456/medium640/makecode_IMG_1248.jpg?1552074923)

Warning: 

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/072/645/medium800/makecode_IMG_2531.jpg?1552430289)

## The Rudder
There is a lot of experimenting to be had in the rudder department.&nbsp;

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.&nbsp;

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

&nbsp;

Straighten out a paper clip.

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

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

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

![makecode_IMG_2283.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/114/medium640/makecode_IMG_2283.jpg?1551460291)

![makecode_IMG_2286.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/116/medium640/makecode_IMG_2286.jpg?1551460349)

![makecode_IMG_2288.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/118/medium640/makecode_IMG_2288.jpg?1551460529)

![makecode_IMG_2477.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/640/medium640/makecode_IMG_2477.jpg?1552428180)

## Fish-Tail Rudder

&nbsp;

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.

![makecode_IMG_1231.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/641/medium640/makecode_IMG_1231.jpg?1552428444)

![makecode_IMG_1233.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/642/medium640/makecode_IMG_1233.jpg?1552429824)

![makecode_IMG_1234.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/643/medium640/makecode_IMG_1234.jpg?1552429866)

![makecode_IMG_1242.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/644/medium640/makecode_IMG_1242.jpg?1552430032)

Test out your rudder to see how it moves!

![](https://cdn-learn.adafruit.com/assets/assets/000/072/757/medium800thumb/makecode_rudder_test2.2019-03-14_12_18_22.jpg?1552580356)

## Attach Rudder

&nbsp;

Attach the rudder of your choice to the servo motor.

![makecode_IMG_1250.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/457/medium640/makecode_IMG_1250.jpg?1552075015)

![makecode_IMG_1251.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/459/medium640/makecode_IMG_1251.jpg?1552075406)

## Water Resistance

&nbsp;

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

![makecode_IMG_1252.jpg](https://cdn-learn.adafruit.com/assets/assets/000/072/484/medium640/makecode_IMG_1252.jpg?1552077197)

# Buttermilk Boat with Circuit Playground Express

## MakeCode Level 1: Free Fall

![](https://cdn-learn.adafruit.com/assets/assets/000/072/141/medium800/makecode.jpg?1551471889)

## Getting Familiar

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

If you'd like to learn more about MakeCode,&nbsp;[this guide is a good place to start](https://learn.adafruit.com/makecode/downloading-and-flashing?embeds=allow).

![](https://cdn-learn.adafruit.com/assets/assets/000/072/765/medium800thumb/makecode_circuit_playground_projects_CPX_bootloader_mode.jpg?1552581680)

## 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&nbsp; **red briefly, then turn green.&nbsp;** Your computer should now show removable drive called&nbsp; **CPLAYBOOT.&nbsp;**

Click the&nbsp; **Download** &nbsp;button to download the **&nbsp;.uf2 file** &nbsp;to your computer, and&nbsp; **drag 'n drop that .UF2 file onto the CPLAYBOOT** &nbsp;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!

https://makecode.adafruit.com/97214-35025-86841-04998

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&nbsp;`on_start`&nbsp;loop, we tell Circuit Playground Express to move the servo motor connected to pin&nbsp; **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&nbsp;`on free fall`&nbsp;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°.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/072/132/medium800/makecode_Screen_Shot_2019-03-01_at_12.34.02_PM.png?1551463710)

## Go Swimming!&nbsp;

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.

![](https://cdn-learn.adafruit.com/assets/assets/000/072/814/medium800thumb/makecode_swimming.2019-03-12_14_22_36.jpg?1552592158)

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?

![](https://cdn-learn.adafruit.com/assets/assets/000/072/815/medium800thumb/makecode_segmented_rudder.2019-03-14_11_55_44.jpg?1552592178)

## Troubleshooting

**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 **&nbsp;** battery pack is set to "ON".

**Problem:&nbsp;** My Circuit Playground Express doesn't show up as&nbsp; **CPLAYBOOT**

**Solutions:**

- Be sure you have a Circuit Playground Express.&nbsp; 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.&nbsp;&nbsp;
- With the Circuit Playground plugged into your computer with a micro USB cable,&nbsp; **click the small reset button** &nbsp;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&nbsp;[Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express)&nbsp;guide for more suggestions.

# Buttermilk Boat with Circuit Playground Express

## MakeCode Level 2: Remote Control

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** &nbsp;is the big clear LED on the left, and&nbsp;the darker&nbsp; **receiver** &nbsp;LED on the right will&nbsp;receive the 38KHz signals and demodulate them for you.

![makecode_circuit_playground_ir.jpg](https://cdn-learn.adafruit.com/assets/assets/000/073/143/medium640/makecode_circuit_playground_ir.jpg?1552662473)

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

https://makecode.adafruit.com/86658-02545-32316-60810

![](https://cdn-learn.adafruit.com/assets/assets/000/072/634/medium800/makecode_Screen_Shot_2019-03-12_at_2.35.30_PM.png?1552420947)

## 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.&nbsp;

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.&nbsp;

https://makecode.adafruit.com/90872-11376-82082-32598

![](https://cdn-learn.adafruit.com/assets/assets/000/072/631/medium800/makecode_Screen_Shot_2019-03-12_at_2.37.18_PM.png?1552419841)

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.&nbsp;

![](https://cdn-learn.adafruit.com/assets/assets/000/072/816/medium800thumb/makecode_remote_control.2019-03-12_14_12_37.jpg?1552592211)


## Featured Products

### Circuit Playground Express

[Circuit Playground Express](https://www.adafruit.com/product/3333)
 **Circuit Playground Express** is the next step towards a perfect introduction to electronics and programming. We've taken the original Circuit Playground Classic and made it even better! Not only did we pack even more sensors in, we also made it even easier to...

In Stock
[Buy Now](https://www.adafruit.com/product/3333)
[Related Guides to the Product](https://learn.adafruit.com/products/3333/guides)
### Micro servo

[Micro servo](https://www.adafruit.com/product/169)
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 code, hardware, or library to control these servos. Good for beginners who want to make stuff move without...

Out of Stock
[Buy Now](https://www.adafruit.com/product/169)
[Related Guides to the Product](https://learn.adafruit.com/products/169/guides)
### Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces

[Small Alligator Clip to Male Jumper Wire Bundle - 6 Pieces](https://www.adafruit.com/product/3448)
When working&nbsp;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 compact jumper cables have a premium male header on one end and a grippy mini alligator clip on the...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3448)
[Related Guides to the Product](https://learn.adafruit.com/products/3448/guides)
### JST 2-pin Extension Cable with On/Off Switch - JST PH2

[JST 2-pin Extension Cable with On/Off Switch - JST PH2](https://www.adafruit.com/product/3064)
By popular request - we now have a way you can turn on-and-off Lithium Polymer batteries without unplugging them.

This **PH2 Female/Male&nbsp;JST 2-pin Extension Cable&nbsp;** comes with an in-line **Switch** - click once to turn on, click again to turn off....

In Stock
[Buy Now](https://www.adafruit.com/product/3064)
[Related Guides to the Product](https://learn.adafruit.com/products/3064/guides)
### Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh

[Lithium Ion Polymer Battery Ideal For Feathers - 3.7V 400mAh](https://www.adafruit.com/product/3898)
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 battery has a capacity of **400mAh** for a total of about 1.9 Wh. If you need a larger (or smaller!)...

Out of Stock
[Buy Now](https://www.adafruit.com/product/3898)
[Related Guides to the Product](https://learn.adafruit.com/products/3898/guides)
### 3 x AAA Battery Holder with On/Off Switch and 2-Pin JST

[3 x AAA Battery Holder with On/Off Switch and 2-Pin JST](https://www.adafruit.com/product/727)
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 3.3-4.5V, a very similar range to Lithium Ion/polymer (Li-Ion) batteries and have an on-off switch. That makes...

In Stock
[Buy Now](https://www.adafruit.com/product/727)
[Related Guides to the Product](https://learn.adafruit.com/products/727/guides)
### Alkaline AAA batteries - 3 pack

[Alkaline AAA batteries - 3 pack](https://www.adafruit.com/product/3520)
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 pack of **3 AAA batteries**.  
  
These batteries are Alkaline (MnO2) chemistry, with a...

In Stock
[Buy Now](https://www.adafruit.com/product/3520)
[Related Guides to the Product](https://learn.adafruit.com/products/3520/guides)

## Related Guides

- [Adafruit Circuit Playground Express](https://learn.adafruit.com/adafruit-circuit-playground-express.md)
- [ Memory-saving tips for CircuitPython](https://learn.adafruit.com/memory-saving-tips-for-circuitpython.md)
- [Make It Glow - Your First NeoPixel Project](https://learn.adafruit.com/make-it-glow-your-first-neopixel-project.md)
- [Soil Moisture Sensor with Circuit Playground Express and MakeCode](https://learn.adafruit.com/soil-moisture-sensor-with-circuit-playground-express.md)
- [Extending CircuitPython: An Introduction](https://learn.adafruit.com/extending-circuitpython.md)
- [Motorized Grinch Fireplace](https://learn.adafruit.com/grinch-fireplace.md)
- [FruitBox Sequencer: Musically Delicious Step Pattern Generator ](https://learn.adafruit.com/circuitpython-fruitbox-sequencer-musically-delicious-step-pattern-generator.md)
- [Make It Sense](https://learn.adafruit.com/make-it-sense.md)
- [Automatic Mechanical Watch Winder](https://learn.adafruit.com/automatic-mechanical-watch-winder.md)
- [Make It Talk](https://learn.adafruit.com/make-it-talk.md)
- [Snap Fit Mount for Circuit Playground Express](https://learn.adafruit.com/snap-fit-mount-for-circuit-playground-express.md)
- [Infrared Transmit and Receive on Circuit Playground Express in C++](https://learn.adafruit.com/infrared-transmit-and-receive-on-circuit-playground-express-in-c-plus-plus-2.md)
- [Trash Panda](https://learn.adafruit.com/trash-panda-circuit-python-crickit.md)
- [Circuit Playground Slouch Detector](https://learn.adafruit.com/circuit-playground-slouch-detector.md)
- [CircuitPython Hardware: PCA9685 DC Motor & Stepper Driver](https://learn.adafruit.com/micropython-hardware-pca9685-dc-motor-and-stepper-driver.md)
- [Four Seasons Fairy Bottle Lanterns](https://learn.adafruit.com/four-seasons-fairy-bottle-lanterns.md)
