A bumper car is usually driven by a crazed carnival-goer -- but we're going to build a self-driving Bumper Bot! This bot will use the Circuit Playground Express for brains and collision detection with its onboard accelerometer. The Crickit will provide all the muscle needed to drive two TT DC gearbox motors, as well as a micro servo direction indicator flag.

A small speaker and NeoPixels will also give us feedback while to bumper bot is out there having fun!!

Parts

1 x Adafruit CRICKIT
for Circuit Playground Express
1 x Circuit Playground Express
Round, Awesome Microcontroller Board
2 x TT Motor DC Gearbox
200 RPM 3 to 6VDC
2 x Orange and Clear TT Motor Wheel
for TT DC gearbox motor
1 x Micro Servo
180 degree rotation servo
1 x Male DC Power adapter
2.1mm plug to screw terminal block

Materials and Tools

  • Small and medium corrugated cardboard boxes
  • Ruler
  • Hobby knife or scissors
  • Paper clip or safety pin
  • Double stick foam tape

You can watch the John Park's Workshop livestream build of the Bumper Bot here:

Cut the Cardboard Chassis

  • Draw some guides for cutting your chassis -- it doesn't have to match this one exactly, just so long as there's room for the parts you can get creative with it!
  • Looking through the rest of this page will give you an idea of the size needed for proper parts placement -- make sure there's enough room between the motors for your battery pack
  • Use a hobby knife or scissors to cut the chassis to shape
  • A rounded front will work well for the bumper car action

Attach Motors

  • Use double stick foam tape to connect the motors to the underside of the chassis
  • Keep them straight and even with each other so the cart will drive straighter than if they're offset

Add Battery Pack

  • Mount the battery pack underneath the chassis between the two motors
  • A couple of piece of double stick foam tape will work well

Connect Wheels

  • The wheels connect by pressing them onto the axles
  • There are two flatted sides of the axle that fit the shape of the wheels' attachment holes

Affix Crickit

  • The Crickit and Circuit Playground Express go on the top side of the chassis between the two wheels
  • Play with the placement a bit so that the cart is slightly tail heavy to make sure it won't tip forward in use
  • Use double stick foam tape to affix it
  • You can double up or even pad the tape with a cardboard layer sandwich to make sure it sticks well, particularly if your Crickit has the rubber feet bumpers on it!

Plug In Power

Plug the battery connector into the Crickit power jack.

Connect Motor Wiring

  • Plug the motor wires into the Crickit's Motor 1 and Motor 2 ports
  • Left motor goes to Motor 1 port
  • Right motor goes to Motor 2 port
  • Follow the pictures for black and red wire assignments -- getting this backwards isn't a big deal, because it can always be reversed in software!

Paper Clip Tail Dragger

A tail dragging bot needs something to smoothly glide across the ground while providing stability for the cart. Sometimes a ball caster is used for this, but we can get away with something much simpler here -- a paper clip! Our bumper bot is light enough that the humble paper clip will provide the needed stability and smoothness on the surface.

  • Poke the paper clip through the tail as shown
  • You can add stability by gluing or taping on a small piece of additional cardboard for thickness

Add Speaker

  • Use tape or poster putty to attach the speaker to the chassis
  • Insert the wires into the Crickit's speaker terminals (either wire can go in either port) and then screw them down

Connect Servo

  • Use double stick foam tape to connect the micro servo to the chassis, leaving room for the servo arm to turn a full range
  • Place a servo horn on the servo shaft so that it can sweep forward and backward
  • Connect a popsicle stick or other material to the servo horn so that it can wave like an indicator flag
  • Plug the servo connector into the Crickit's Servo 1 port with the yellow wire closest to the outer edge of the Crickit

Mount the Bumper

This step is optional, but you may find it helpful. You can add a cardboard bumper to the front of the bumper bot so that it won't accidentally drive over lower obstacles that are cleared by the chassis.

  • Cut a length of cardboard that is a bit wider than the cart chassis and that reaches from the front down about 3/4 of the way to the ground
  • Cut away a groove of the face and fluting along the length of the cardboard so it can butt up against the connection point
  • Bend the cardboard to fit the curve of your cart's front
  • Glue the joint and then connect the two pieces, holding them in place while the glue cures

Next, it's time to code the Bumper Bot with MakeCode.

You can code your Crickit and Circuit Playground Express using MakeCode! If you aren't already familiar with MakeCode, check out this guide to get started, then return here when you're ready.

Crickit Extension

The good folks at Microsoft's MakeCode team have been busily adding Crickit functionality to MakeCode! Currently, this works with the beta version of MakeCode, so click this link to get started. Then, create a new project.

To enable Crickit functionality in MakeCode, click on the Advanced category, then click on Extensions.

Then, type 'crickit' in the text field and press enter. The Crickit package will appear. Click on it and it'll be added to MakeCode!

Now that the package has been added, you'll see a new block category appear named Crickit

Click on the Crickit category to see all of the things you'll be able to do.

Crickit Run Motor

We'll start with the fundamental block for our program -- crickit run motor

Add one of these blocks to the Forever block. This will cause Motor 1 to run at half speed, forever!

Name and download the program, saving the .uf2 file to a directory you can easily find.

Then, plug the Circuit Playground Express (CPX) into you computer over USB (make sure to plug into the CPX USB port, not the one on the Crickit, which is used for occasional firmware updates) click the reset button on the CPX once to enter bootloader mode. Copy the .uf2 file to the CPX by dragging it to the CPLAYBOOT drive that appears.

Make sure the battery pack is plugged into the Crickit, and that the Crickit's power switch is in the 'on' position.

When the Circuit Playground Express restarts, it will tell the Crickit to run the motor. It's alive!! This will cause your Bumper Bot to turn in a circle. Turn off the Crickit board, and now we'll put the full program on it!

Bumper Bot Program Flow

Here's the flow we'll follow for our program:

  • Turn on the bot, it will:
    • play a sound
    • set the NeoPixels to yellow
    • move the servo flag up
  • Press button A on the CPX and it'll:
    • play a tone
    • set the NeoPixels blue
    • move the motors forward to start driving
    • flip the flag direction
  • Press button B to:
    • stop the motors
    • play a double beep
    • set pixels to magenta
    • move the flag
  • When the bot hits an object, the accelerometer shake condition is met:
    • stop both motors
    • reverse the motor direction
    • play a double beep
    • set the pixels to purple
    • move the flag
    • run both motors backwards for a little bit
    • stop Motor 2
    • run Motor 1, which causes the bot to turn
    • run the motors forward
    • set the pixels blue
    • rotate the flag

Following these steps, we create the program below. You can download the code and copy it to your Circuit Playground Express.

If you'd like to make changes, it's easy! How about different colors for the pixles? Change the sounds! Rotate the opposite direction when turning! There are so many choices for what you can do with your Bumper Bot and MakeCode!

Make sure you follow the step above to add the Crickit extension before clicking the link below! Otherwise, the editor will take you straight to JavaScript mode instead of blocks and throw some other errors.
Be sure you use the green Servo blocks under the CRICKIT group and NOT the red Servo blocks under the PINS block group!

On the next page, we'll put the bot into action!

Now you can set your Bumper Bot free! First, set the bot down on a smooth surface, such as a workbench or floor. Then, turn on the Crickit's power switch. It will boot up, light the NeoPixel ring yellow, play a startup beep, and move the servo mounted flag. Press the A button, and off it goes!

When it hits a wall or other solid obstacle, the accelerometer will sense the shake and reverse the motors, then turn, and start going forward again.

If the bot hits a soft obstacle it may not be enough to trigger the accelerometer shake detection, so you will need to help your robot friend along a bit! You can see this in the above video.

Should your bot begin to behave strangely, such as running forever in reverse after a collision, or not moving consistantly - replace the batteries! Low batteries can't supply enough current and will cause the board to reboot or odd/slow behavior!

Have fun running your robot! You can create obstacle courses with coffee cans filled with sand or rocks, or even build two bots and have them battle each other for space!

This guide was first published on Jun 13, 2018. It was last updated on Jun 13, 2018.