Save the Wee Turtles

The plight of baby sea turtles trying to find their way to the ocean is one that has played out for millennia, and become increasingly harrowing as humans habitation has encroaches on some of their ancestral nesting grounds.

This project demonstrates how to build a robotic turtle that will respond to light, triggering it to start flapping its flippers and moving, hopefully, toward the freedom of the ocean.

The tools and materials for this project (aside from the motors and microcontroller) are things you can find around the home. Paired with the versatile robotics platform, CRICKIT for Circuit Playground Express, simple household materials can spring to life and take on any form your imagination desires!

This project demonstrates basic programming skills using Microsoft MakeCode and allows for easy experimentation and adaptation. 

Household Materials

  • Cardboard
  • Paper
  • Scissors
  • Screwdriver
  • Double-sided tape
  • Zip ties (or twist ties/wire)

Adafruit Electronics

1 x Circuit Playground Express
Circuit Playground Express is the perfect introduction to electronics and programming
1 x Adafruit CRICKIT for Circuit Playground Express
Creative Robotics and Interactive Construction Kit is an add-on to Circuit Playground Express that lets you #MakeRobotFriend using CircuitPython and MakeCode
2 x DC Gearbox Motor - "TT Motor" - 200RPM - 3 to 6VDC
TT DC Gearbox Motor with a gear ratio of 1:48 and 2 x 200mm wires with breadboard-friendly 0.1" male connectors
2 x Snap-on Hub for TT Motor
This motor hub snaps onto the TT motor and is a good solution to quickly and easily add custom parts to your robot project
1 x Alkaline AA batteries - 3 pack
These batteries are good quality at a good price, and work fantastic with any of the kits or projects that use AAs
1 x 3xAA holder with DC jack
Battery holder 3xAA batteries with 2.1mm DC jack
1 x USB cable - A/MicroB - 3ft
Standard A to micro-B USB cable

To make your turtle, start by printing out a copy of the sea turtle PDF below (it's a pdf version of this public domain sea turtle drawing)

If you would prefer to personalize your turtle, many other templates are available online under the search term "sea turtle outline". 

Or, use the pdf as a template, and draw your own turtle friend!

Find a piece of scrap cardboard roughly the same size as your turtle.

 

Apply glue to both the back of the paper and the cardboard.

 

Place paper on cardboard and smooth out any air bubbles with another piece of scrap cardboard.

 

Wait 5-10 minutes for the glue to dry, then cut around the outline using scissors or knife.

Remove flippers

Remove the flippers from the body by carefully cutting them away using scissors or a knife.

 

These will get attached to motors and power the turtle forward.

To attach the flippers to the motors, we will use a snap on motor hub

Zip ties or twist ties work great as a method of attachment.

Mark the position of the motor hub against your flipper.

 

Poke two holes through flipper using something pointy. 

 

Use zip-ties or twist-ties to hold flipper to motor hub.

Repeat the process for the second flipper.

Depending on your design, you may need to trim the edges of the flipper so that's it's not quite as long.

This step is important to allow the motors to spin all the way around and not get stuck. 

Once these flippers are to your satisfaction, it's time to get them moving!

Let's add some electronics...

Your sea turtle is ready to be outfitted with electronics! We will add the following:

  1. Battery pack
  2. Motors 
  3. CRICKIT microcontroller

Add the battery

Use screws provided to attach battery pack.

 

Mark the position of the two center holes with a pen.

 

Use screwdriver to poke holes in the cardboard. Don't widen the holes too much, the screw threads will grip the cardboard and pull themselves through. 

 

Tighten the battery pack into place. 

Attach motors

 

Mark the position of the motors with a pen or pencil.

 

Use double-sided foam tape to stick motors to underside of turtle.

 

Press hard to ensure strong bond.

Attach CRICKIT

Use twist-ties to hold CRICKIT on turtle's back.

 

Mark the position of two CRICKIT mounting holes.

 

Poke these holes all the way through the cardboard.

 

Thread your ties through these holes, tightening them to hold CRICKIT in place on your turtle's back.

Think carefully about the orientation of CRICKIT on your turtle's back, as you want to make sure motor and power connections are both accessible!

Connect motors

Plug the ends of your motor cables into the terminal blocks on the "Motor" section of CRICKIT. 

Tighten these connections down with a screwdriver.

Make sure to load up your turtle with fresh batteries. These motors can get power hungry and your turtle may have trouble getting around if your batteries are low.

Now it's time to upload some code! For this we will be using Microsoft MakeCode for Adafruit, a web-based code editor. It provides a block editor, similar to Scratch or Code.org, and also a JavaScript editor for more advanced users.

If you haven't used MakeCode before, this guide is a good place to start.

Getting into Bootloader Mode

Your Circuit Playground Express board comes ready to work with CircuitPython. When you connect the board to your computer for the first time, it will appear as a flash (or thumb) drive named CIRCUITPY.

BUT...

We'd like to make it work with MakeCode, 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. 

The Code

Follow this link or enter the portal below to interact with the code used in this project.

How to upload 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!

What this code does

This sketch in MakeCode uses the light sensor on Circuit Playground Express to control the motors.

In the on start block we can see that there is a startup animation and a command to invert the direction of one of the motors is so they will both spin in the same direction when placed in parallel. There is also a graph command, which indicates the light level by illuminating more or fewer of the 10 neopixels on the CPX board. 

In the forever block there is an if / else statement, which gives the following instructions:

  • If light level goes above the specified value, start spinning the motors in tandem.
  • If light level goes below the specified value (in this case, 150), stop the motors. 

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.

You can test this out by holding your turtle under bright light and covering/uncovering the light sensor.

Light Sensor

The component that makes this possible is the tiny analog light sensor in the top left part of the board. This is used to detect ambient light with similar spectral response to the human eye.

With MakeCode we are able to use the readings coming from this light sensor to control the motors, but it's also possible, with some clever code, to use this as a color sensor or even a pulse sensor!

Making Changes

If you want to make changes to your program you can connect your CPX to your computer with a micro USB cable, download your adapted code, and drag the new .uf2 file onto your CPLAYBOOT drive.

It is recommended that you remove the turtle's flippers while making changes so the turtle doesn't run away on you.

Troubleshooting

Problem: My flippers aren't rotating!

Solution: Make sure that the small slide switch on the CRICKIT is set to "ON".

 

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.

Depending on where you set your turtle, the ambient light available may be enough to trigger it to start flapping without a need for a flashlight.

You can change how sensitive your turtle is to light by changing the value in the if light level > 150 block of code. 

Have fun playing with your turtle! See what obstacles it can climb over, or experiment with other ways to trigger the motors to turn, such as sound, a button click, or vibration!

If you'd like to customize your turtle, color it with markers or add craft paper, glitter/sequins, feel free to get creative with the design!

More MakeCode!

If you enjoy MakeCode and want to continue exploring you can check out lots more MakeCode projects on the Adafruit Learn System.

This guide was first published on Jul 24, 2018. It was last updated on Mar 08, 2024.