The best tools to make your project dreams come true

Login or Signup
USD


By Adafruit Industries

Stumble-Bot

Courtesy of Adafruit

Overview

Here is a fun robot you can build with a cardboard box. 

 

Figure 1

Simply Stumbling

Stumble-bot moves using servo controlled legs controlled by the Adafruit Crickit– A Creative Robotics & Interactive Construction Kit.

The design of this walking robot has the advantage of being very simple. As a result, it requires relatively few parts.

Figure 2

We Have the Technology

This project pairs CRICKIT and Circuit Playground Express with two servo motors.

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 our popular Circuit Playground Express that lets you #MakeRobotFriend using CircuitPython

1 x USB cable - A/MicroB - 3ft: Standard A to micro-B USB cable

1 x TowerPro SG-5010 Servo: High-torque standard servo can rotate approximately 180 degrees (90 in each direction)

1 x Micro servo: This little servo can rotate approximately 180 degrees (90 in each direction). Works just like standard servos you're used to but smaller.

1 x 3 x AA Battery Holder with On/Off Switch: This battery holder connects 3 AA batteries together in series for powering all kinds of projects.

1 x Male DC Power adapter - 2.1mm plug to screw terminal block: If you need to connect a battery pack or wired power supply to a board that has a DC jack - this adapter will come in very handy!

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.

Other Supplies

In addition to the electronics, you will need the following essentials:

Optionally, you may want to include popsicle sticks and some googly eyes along with the rest of your supplies.

Figure 3

Figure 4

Leg Assembly

The top portion of the box will become the legs.

Figure 5

Trace out rough outlines of the legs on top of the box.

The front legs will be made from three pieces of cardboard glued together. The back legs can be made from a simple U-shaped piece of cardboard.

Cut out a big square around the legs you've outlined using scissors or an X-acto knife.

Once you've extracted the top piece of cardboard, follow the lines to cut out the leg parts.

WARNING! BURN HAZARD! Hot glue is very sticky and it's easy to accidentally burn your fingertips. Be careful when using it.

Front Legs

The front legs will pull our bot forward, so they need to be strong.

Figure 7

Add a line of hot glue about 1/8" from the edge.

Squash leg into the middle of the line of hot glue.

Hold it in place for about 30 seconds, being careful to keep it at 90 degrees!

Add a thin line of hot glue along each edge to provide more support. Do the same for the other side.

Figure 8

Now we'll add a popsicle stick to strengthen the leg. You may also use a thin piece of wood or some stiff cardboard.

Make a line of hot glue along one outside edge of the cardboard. Press popsicle stick down.

Use hot glue or double sided tape to fasten servo hub to the top of the leg assembly.

Back Legs

The back legs will pivot back and forth, coordinating our bot's steps.

You may want to trim the corners off each back foot at this point.

Figure 9

Figure 10

Mark the center point where the servo hub will attach

Use hot glue to add a popsicle stick (or bamboo skewer or similar). This will strengthen the cardboard leg.

Use double sided tape to stick the servo hub to the finished leg.

Build It!

We will mount our two servo motors so they're pointing perpendicular to each other.

Front servo

Please be careful with paper cutting knives and scissors.

Figure 11

Figure 12

The larger of the two servos, the SG-5010, will be used to power the front legs.

Trace the outline of the servo housing on the bottom of the box, about an inch from the front edge. Carefully cut out this hole using a cardboard knife or an X-acto blade.

Feed the wires through the hole from the bottom.

Press the servo housing into the hole.

Back servo

Figure 13

Use a pencil to trace the outline of the smaller servo motor on the back edge of the box.

IMPORTANT: Position the servo so the central rotation point is directly in the middle.

Cut out this hole with a cardboard knife or x-acto blade.

Press fit your servo motor into this hole.

Glue motors in place

DANGER! BURN WARNING! Hot glue is very sticky and it's easy to accidentally burn your fingertips. Be careful when using it.

Figure 14

Use dabs of hot glue around both servos to hold them firmly in place.

Attach the Legs

Figure 15

IMPORTANT! Rotate the servos back and forth to see where their extents are (how far they move in each direction until they stop). Move the servo with a horn attached gently in both directions until it stops. When done, pick the rough middle of the 180 degree pivot range.

Mount the legs in the middle, so they are free to rotate about 90 degrees in each direction.

Mount servo hubs onto the motors.

Use the provided screws to fasten the legs firmly to the servo horn.

Trim the Legs

The front legs may need to be trimmed down so the robot sits about level.

 

Figure 16

Trim the corners off each front foot to prevent the edges from getting caught on small obstacles as it stumbles along.

Figure 17

Connect Everything

Prepare your battery pack

If your battery pack doesn't have a 2.1mm DC jack attached already, you'll need to add one.

Three AA alkaline batteries are recommended to power CRICKIT. Alkaline batteries have a 1.5V max voltage, so 3 of them in series provides a steady 4.5V output. Perfect for CRICKIT!

If your battery pack already has a DC jack attached, you can skip this step.

Figure 18

Remove batteries before hacking on your battery pack! Snip the JST connector off your battery pack. We won't be needing this.

Strip about 1/4" insulation off the end of the red and black wires.

Screw these wires into DC terminal block.

OPTIONAL: Peel back and remove the belt clip from back of the battery pack. This will make it easier to mount into your box.

Attach Servos

Figure 19

Figure 20

Connect servos to your CRICKIT board.

Be sure the yellow wire faces the edge of the CRICKIT board and the brown/black wire faces the Circuit Playground Express.

Connect your DC plug to the power jack on your CRICKIT board.

Use double sided tape to stick your battery pack to the inside of the box and CRICKIT on top of that.

Connect Circuit Playground Express to your computer with micro USB cable.

Make sure the battery pack and Crickit switches are set to "ON"!

Once everything is connected you're ready to move on to The Code!

Figure 21

Let's stumble onwards!

The Code

Synchronized Servos

We will use the Mu Python editor to upload the CircuitPython code to Circuit Playground Express and control both servos simultaneously.

If you've not used CircuitPython before, set up and try it out with the Circuit Playground Express by following our installation/tutorial pages for the product, learning about CircuitPython and reading our CircuitPython on Circuit Playground Express guide.

If you have not used Mu before, follow this guide on how to install it

For a quick primer on using CircuitPython and Crickit, it is recommended to read through this learn guide.

Figure 22

Uploading

Make sure you've connected the Circuit Playground Express to your computer and have Mu open and connected to your board.

 Figure 23

Copy and paste the code below into your Mu editor.

Save this code to your CIRCUITPY drive in your computer's file exploration program.

Copy Code
# Stumble bot, coded in CircuitPython
# Using an Adafruit Circuit Playground Express, Crickit, and 2 servos
# Dano Wall, Mike Barela for Adafruit Industries, MIT License, May, 2018
#
import time
import board
from digitalio import DigitalInOut, Direction, Pull
from adafruit_crickit import crickit

led = DigitalInOut(board.D13) # Set up Red LED
led.direction = Direction.OUTPUT

button_A = DigitalInOut(board.BUTTON_A) # Set up switch A
button_A.direction = Direction.INPUT
button_A.pull = Pull.DOWN

# Create servos list
servos = crickit.servo_1, crickit.servo_2

# TowerPro servos like 500/2500 pulsewidths
servos0.set_pulse_width_range(min_pulse=500, max_pulse=2500)
servos1.set_pulse_width_range(min_pulse=500, max_pulse=2500)

# starting angle, middle
servos1.angle = 90
servos0.angle = 90

def servo_front(direction):
if direction > 0:
index = 50
while index <= 100:
servos1.angle = index
time.sleep(0.040)
index = index + 2
if direction < 0:
index = 100
while index >= 50:
servos1.angle = index
time.sleep(0.040)
index = index - 2
time.sleep(0.002)

def servo_back(direction):
if direction > 0:
index = 60
while index <= 90:
servos0.angle = index
time.sleep(0.040)
index = index + 4
if direction < 0:
index = 100
while index >= 50:
servos0.angle = index
time.sleep(0.040)
index = index - 4
time.sleep(0.020)

print("Its Stumble Bot Time")

while True:
if button_A.value: # If button A is pressed, start bot
led.value = True # Turn on LED 13 to show we're gone!
for i in range(5):
print("back 1")
servo_back(1)
time.sleep(0.100)
print("front 1")
servo_front(1)
time.sleep(0.100)
print("back 2")
servo_back(-1)
time.sleep(0.100)
print("front 2")
servo_front(-1)
time.sleep(0.100)
led.value = False
# end if
# end while

Click the A button on the Circuit Playground to see it move!

Make sure the file saved to CIRCUITPY is named "code.py", this will allow it to run automatically when your CPX is powered on.

Figure 1

Troubleshooting

Problem: My servos aren't turning!

Solution: Check that the switches on both CRICKIT and your battery pack are set to "ON".

Problem: My Circuit Playground Express isn't recognized by Mu!

Solution: Make sure your board is set up as a CIRCUITPY device. If it is showing up at "CPLAYBOOT" on your computer, you can follow the steps in this guide to get it back into CIRCUITPY mode.

Calibrating the Legs

You may notice that the movement of either or both of your robot's legs is not symmetrical.

There are two ways to go about calibrating the position of the legs so that your robot's gait is smooth(ish). Choose your preferred method below.

Digital Calibration

While connected to your computer, you can use Mu to quickly dial in the numbers for each servo.

In Mu, click on the REPL icon and watch the printout at the bottom of the program to see which leg movement is related to which block of code.

It may be helpful to label each leg something like "Front 1", "Back 1", "Front 2", "Back 2", to help keep track of each of them.

Figure 24

Figure 25

Figure 26

Change the numbers in index = 50 and while index <= 100 to alter the swing of each leg.

The front legs should alternate about 40 degrees back and forth.

The back legs swing about 30 degrees up and down.

Figure 27

Analog Calibration

Alternatively, if you prefer a more hands-on method, you can skip the programming side of things and simply remove the legs and reposition them as needed.

This method can take some time to get exactly right, but works well if you aren't able to connect to a computer and update the code.py file.

Figure 28

Calibrated legs should move equally in both directions.

Figure 29

Finishing Touches

If you find your robot sliding around, adding a thin line of hot glue or other grippy substance to the toes of the front legs can help give it traction.

 Figure 30

 Googly eyes and other decorations are a fun way of personalizing your Stumble-bot.

You can use markers or crayons to add personal touches.

Figure 31

Some pipe cleaners can easily give your robot a more alien appearance!

Figure 32

Happy Stumbling!

Figure 33

Exploring further

If you enjoy CircuitPython and want to continue learning you can find lots more CircuitPython projects on the Adafruit Learn System.

Key Parts and Components

Add all Digi-Key Parts to Cart
  • 1528-2280-ND
  • 1528-2631-ND
  • 1175-1809-ND
  • 1528-1075-ND
  • 1528-1076-ND
  • 1528-1817-ND
  • 1528-1387-ND
  • P646-ND
  • 3M157345-ND