Looking for a way to get kids designing and building their own simple robots? With just a Circuit Playground Express (CPX), a servo motor, and a few household materials, anyone can create a Cardboard Inchworm that meets the "sense-think-act" definition of a robot! Here's how:
- The Cardboard Inchworm can sense a loud sound using the audio sensor (microphone) built into the CPX.
- Then it can think about how to react, thanks to the CPX's powerful microcontroller brain.
- Finally, it can act by triggering the servo motor to repeatedly pull the front and back of the Inchworm together and letting them slide apart, creating a slow but steady crawling motion.
The Inchworm is quick to build, and Microsoft MakeCode makes it super-easy to program! And it also lends itself to multiple variations in materials and structure. See if you can figure out how to make your Inchworm go even faster and crawl over more kinds of surfaces!
When you're done, it's also easy to remove the CPX and accessories and use them in another project. The rest of the Inchworm can be recycled. That's why programmable cardboard robots are a great first electronics project for kids and beginners!
Parts List -- Electronics
The Circuit Playground Express Base Kit is a good choice for this project, because it comes with the USB cable to program the board, a battery holder, and three AAA batteries. You can also buy the Circuit Playground Express and accessories separately.
Circuit Playground Express - Base Kit
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming. Kit includes the Circuit Playground Express, USB cable - A/MicroB, 3 Alkaline AAA batteries, Battery Holder, and a Mini Storage Box.
Circuit Playground Express
Circuit Playground Express is the next step towards a perfect introduction to electronics and programming.
Alkaline AAA batteries - 3 pack
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.
A tiny little servo that can rotate approximately 180 degrees (90 in each direction).
Materials List -- Household and Crafts Supplies
Other supplies you will need include:
- 1 strip of sturdy cardboard roughly 14 inches by 4.5 inches -- thin corrugated cardboard works well
- masking tape
- adhesive dots -- extra strength is best
- peel-and-stick Velcro dots
- 1 large metal paper clip
- (optional) googly eyes
Bending the Cardboard
To bend the cardboard strip into a basic inchworm shape, you need to fold it up in the middle and out at the ends. The feet at each end should be about 2 inches (5 cm) long.
Tip: Use a rounded-tip tool, such as the cap of a pen, to score the cardboard by gently, indenting the line you want to fold. Be careful not to rip through the thin outer layer of the corrugated cardboard.
Give the Feet Some Grip
The feet need to help to grab the surface below them so they can propel the Inchworm along. Some suggestions:
Cut slits along one end to make toes. Then alternately fold one toe up and the next toe down.
You can also make the toes longer and give them some curl.
Caution: Young children should get adult help using a knife or cutter.
Cut Some Teeth
Use a craft knife or small box cutter to make V-shaped teeth . The points of the Vs should face towards the back of the Inchworm.
Bend each tooth down so it sticks out on the underside of the foot.
If you bend the edge of the foot up, the front row of teeth will point directly down for extra bite.
Make simple fangs by folding down the corners of the foot.
Or use scissors to cut a zigzag line of fangs along the edge.
Other suggestions creating rubbery treads on the bottom of the feet using dabs or lines of hot glue.
The sample Inchworm in this guide uses teeth in the front and straight toes in the back.
The best solution depends on the kind of cardboard and the texture of the surface it will be crawling over, such as carpeting.
Tip: A strip of felt makes a good crawling surface.
To make your Inchworm go, you need to attach the Circuit Playground Express board, the battery pack, and the servo to the cardboard body. And everything has to be connected with wires, without letting them get in the way of the moving parts.
Where you place them is up to you. Depending on the weight of the cardboard you use for the body and what kind of feet you give it, you may get better results by putting more weight in the front, or lower down, or other variations on the arrangement shown in this example. Play around and see what works best for you!
Peel-and-stick Velcro dots let you reposition or remove the CPX as needed. They also give you some clearance between the CPX board and the cardboard. That makes it easier to attach alligator clips to the board.
Just press one side of the Velcro onto the back of the board and the matching side on the front of the Inchworm.
In the example here, the hook (scratchy) side is attached to the CPX and the loop (soft) side is attached to the cardboard.
Prep the Servo
Unlike a regular motor, a servo can only swing back and forth in a semi-circle, 180 degrees. But a servo is also self-aware -- it knows which direction it's facing. That means with a little coding, you can tell it where to turn!
To make the Inchworm crawl, you will program the servo to turn all the way towards the front, and then swing all the way towards the back, over and over. This motion pulls the front and back of the Inchworm together and then releases them, so the Inchworm moves slowly forward.
But before you attach the servo, you have to set it up so that the arm is facing in the right direction.
Hold the servo so the end with the wires is facing up when you are looking straight down at it. Press the one-armed horn (also called a half horn) onto the shaft of the motor so it is pointing to the right (three o'clock position).
Then use the arm like a handle to turn the shaft of the motor as far to the right as it will go.
Next, lift the arm off the servo, and replace it so it is back in the three o'clock position.
You should now be able to turn the arm 180 degrees from right to left.
The last step in preparing your servo is to wrap a piece of masking tape around the body from one side, across the bottom, and up the other side.
This way the adhesive dot you use to attach the servo to the cardboard robot body will stick to the tape instead of the servo. It makes the servo easier to remove -- and also helps keep the servo firmly attached to the cardboard.
Now that it's prepped and ready to go, you can attach the servo to the cardboard. Extra-strength adhesive dots are a simple way to glue the servo in place.
With the wire end of the servo facing up, stick an adhesive dot onto the right side of the servo.
Press the glued side of the servo onto the cardboard with the wire end facing the front of the Inchworm.
When the Inchworm is standing up, the wires face up towards the top fold in the cardboard.
Battery Holder Options
The battery holder contains your robot's On/Off switch. Make sure to attach the holder with the switch facing out! And position it so the wires face the CPX, since you have to plug them into the JST connector.
Tip: Keep in mind that the battery holder is the heaviest part on the Inchworm. You may want to try sticking it on with tape in different places and giving it a test run with all the electronics working before attaching it permanently.
If you have the battery holder with the belt clip, you can cut a slot in the cardboard and clip it right on. Be careful not to bend the cardboard as you insert it.
If there's no belt clip, use two or more adhesive dots to attach the battery holder to the cardboard.
It's time to connect the electronics to the CPX, then finish the body by hooking the servo to the front of the cardboard body.
Plug the JST battery connector into the Circuit Playground Express black battery connector.
Tip: If you need to unplug the JST connector, be careful not to pull too hard or the wires may break. Wiggle it gently while sliding it slowly out.
Don't forget, you can remove and reposition the Circuit Playground Express to keep the wires out of the way.
Servo Arm to Front of Inchworm
Unbend a paperclip in the middle and straighten it out. The larger end will go towards the front.
Fold the front and back of the Inchworm together, and mark a spot on the front roughly even with the arm. Insert the larger end of the paperclip through the spot.
Insert the end of the smaller loop through the last hole in the servo arm.
With the paperclip attached at both ends, check to see that the Inchworm is as open as you would like it to be.
Then bend the ends to keep them from slipping out.
Time to program your cardboard robot with Microsoft MakeCode for Adafruit!
MakeCode is a web-based code editor designed for beginners that is amazingly simple to learn. You can use it online -- there's no need to download anything. You can build programs quickly with drag-and-drop blocks, similar to Scratch. And best of all, it displays a simulated Circuit Playground Express so you can get an idea of how your program is working before you download your code to the real CPX board.
If you're new to MakeCode and CPX, you can learn more by checking out the Adafruit MakeCode Guide.
How the Inchworm Robot MakeCode Works
The MakeCode program for the Inchworm Robot gives you two ways to try it out:
- When you press Button A, the CPX will show a light animation, signal the servo to swing back and forth five times, and then stop and clear (turn off) the lights.
- A second stack of blocks programs the CPX's built-in microphone to listen for a loud sound. When that input is received, the code runs a different light animation, followed by the same servo sequence, and then clearing the lights.
Use Button A when you want to test the robot's movement, make adjustments, and then test it again at the touch of a button.
Then when you've got the Inchworm moving the way you want it to, use the sound trigger to turn the cardboard creature into a real robot that can sense, think, and act!
Download MakeCode to the CPX
To get started, connect the CPX to your computer with the micro USB cable. Your computer will treat the CPX the same way it does a flash drive, as an extra piece of hardware for storing files. It will show up as a drive called CLAYBOOT. Close any pop-ups that arise; you don't need to do anything with them.
To tell the CPX to get ready to receive code, you need to put it into bootloader mode. Press the tiny Reset button in the middle of the board until all the lights turn red for a second and then switch to green. You may have to press the button a few times the first time you use the CPX, or if it doesn't switch into bootloader mode the first time.
Now go to makecode.com/_9PfVyeYWMYz1 or click on the button below to see the MakeCode program. Click on the "Edit" link to open it up in MakeCode. (You can also click on the small "Download" link at the bottom of the MakeCode screen and load it immediately onto the CPX.)
When you open the program up, you will see the CPX simulator on the left, and the various categories of blocks you can code with listed in the middle. On the right is the code itself. In addition to the stacks of blocks for Button A and the sound sensor, there's a piece of code that runs as
On Start, as soon as you turn on the CPX. It moves the servo arm to the 3 o'clock position, so the Inchworm is spread apart and ready to crawl.
When you are ready to download the program to your CPX, click the pink Download button on the MakeCode page. It will save a file named circuitplayground-Inchworm Robot.uf2 to the CLAYBOOT drive. If your computer automatically saves it to the Downloads folder or some other location, just find the file and drag and drop it (or copy and paste it) into the CLAYBOOT drive.
Running the Inchworm MakeCode Program
You can test your code while your CPX is still connected to the computer by pressing Button A or making a loud sound. Clapping or tapping the table near the Inchworm seems to work well.
To test how well it moves, unplug the USB cable and put the Inchworm on a surface with a little texture, so the teeth have something to grab. Turn the switch on the battery holder to On, and then press Button A or trigger the sound sensor (a loud clap or two works well).
If all goes well, your Inchworm will crawl along on command!
Cardboard robots are not finely-tuned instruments. But learning to identify and fix problems is an excellent skill for robot-builders, so try some of these suggestions:
- If your Inchworm is flexing but it's not getting anywhere, make sure the cuts in the feet are bent down enough to reach the crawling surface. Also try different surfaces, such as a tablecloth, carpet, or piece of felt.
- Increase the weight on the front foot by taping some coins or batteries onto it.
- Make sure the paperclip isn't hitting wires or other parts as it moves. You can tuck wires around the back of the Inchworm.
Playing With the Code
Taking a piece of code that works and messing around with it is a good way to learn how it works. Here are some ways you can change the program and start to get a feel for how MakeCode works:
- On the blue Animation blocks, click on the small image to open a menu of other options. Or click on the Lights menu in the center of the MakeCode screen and build your own light show by adding a stack of
Show Ring blocks. You can change colors by clicking on the palette of hues in the center and then on the light you want to change.
- Make the Inchworm go farther by increase the number on the green
- Change how far the servo arm swings by clicking on the number of degrees on the green
Set Servo To blocks. You will see a slider showing the position of the arm.
- Experiment with other inputs and outputs. For example, you can grab a pink
On Light block from the center menu to control the robot using flashlights. Or add sound by telling the CPX to play a few notes before it starts to crawl.
Have fun! Building quick and simple robots is addictive, so look around to see what other ideas you can build with the CPX, MakeCode, and a little scrap cardboard.