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.
- Double-sided tape
- Zip ties (or twist ties/wire)
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
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 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.
Your sea turtle is ready to be outfitted with electronics! We will add the following:
- Battery pack
- 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.
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.
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!
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.
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.
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.
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.
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.
forever block there is an
if / else statement, which gives the following instructions:
light level goes above the specified value, start spinning the motors in tandem.
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.
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!
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.
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!
If you enjoy MakeCode and want to continue exploring you can check out lots more MakeCode projects on the Adafruit Learn System.