Introduction: How to Make a Shy Robot

About: Ben Lerchin is an artist, software engineer, and digital art fabricator working with experimental photographies, maps and language. Living and working in Oakland CA, Ben collaborates widely with artists and en…

Inspired by Norma Jeane's ShyBot, this Mini Shy Bot is a simple motion-activated bot that will run away from you when you walk into a room.

It's built with SparkFun's RedBot Inventor's Kit, an extensible Arduino based bot platform that's great for experiments.

What you'll need:


How bout you just give me the files, OK?!
Alright sparky. You'll find everything you need on GitHub.

Step 1: Print the Enclosure

Fortunately, the RedBot kit anticipates a lot of our needs. The included Arduino, motor controller, and bump sensors provide us with a functional bot that knows how to navigate around an (obstacle-free) room.

The main modification we'll need to make is the addition of PIR sensors, and an enclosure to point them in the right direction. Good news: I did the work for you and modeled it. The PIR enclosure is designed to mount directly onto the RedBot, and has screw holes to match the PIR sensors, hooray! Or, you know, you could fashion something out of an Altoids tin...

If you ordered a print from Shapeways, you're all set. Move on to the next step.

If you're making your own print, now's a great time to do that. Start with the enclosure, because that print is the only one that's necessary to mount to the robot.

Grab `pir-tower--cap.stl` and `pir-tower--enclosure.stl` from GitHub.

The exact process will to print these files depending on the 3D printer you're using. There are two pieces that have to be printed separately, since without a removable top you wouldn't be able to fit the sensors inside.

While you're waiting for your print to finish, you can start building the bot itself.

Step 2: Build the Bot

Sparkfun has great documentation that you can follow. Check the video above, and the assembly guide for more details:

https://learn.sparkfun.com/tutorials/assembly-guid...

You can feel free to leave off a few things:

  • The line followers are flimsy, and we we won't be using them.
  • The buzzer interferes with the PIR sensors, so we won't be using that, either.
  • We won't be using the accelerometer for this project.

Make sure not to tighten the screws on the bumpers too tightly.

Protip: Superglue some soft plastic on the stabilizer that serves as a "third wheel" to avoid a horrible screeching sound when the bot moves.

Step 3: Install the RedBot Arduino Library

  1. If you don't have the Arduino IDE installed, get it here.
  2. Download the RedBot Arduino library from this page.
  3. Unzip and drag the downloaded folder into your ~/Documents/Arduino/libraries directory to add it to the Arduino IDE.
  4. Plug RedBot into your computer with the included USB cable
  5. Follow directions in the video to set up your IDE with RedBot

Step 4: Test the Motors

The first test we want to run is "Exp2_DriveForward" in the RedBot examples. We'll want to make sure that the wheels turn when we tell them to, and that they both turn in the same direction.

If they don't turn in the same, (forward) direction, just switch the polarity for the leads connected to LEFT MOTOR or RIGHT MOTOR.

Step 5: Test the Bumpers

Next step is to test that the bumpers on the bot work properly. The bumpers are the bot's primary means of interacting with the world (except, of course, for the PIR sensor, which we'll get to later) and allow it to avoid obstacles. Whenever the bot runs into something, the bumper wire will complete a circuit, letting the microcontroller know it should turn around.

For this test, we're going to run "Exp5_Bumpers", in the SparkFun RedBot examples folder.

Step 6: Replace the PIR Connectors

Back to the workbench

The PIR sensors we ordered from Sparkfun come with JST connectors, which are lovely except that they won't mate with the headers on our RedBot's board. The pitch (spacing of the holes in the connector) is off compared to the servo-style connectors our board expects. They're also wired in the wrong order.

We'll need to solder on headers to get around this issue. If you're lazy or can't solder, it's also OK to use Female-Male jumpers to connect JST to the board. Just take care to connect the leads in the right order, and attach them somehow that they won't easily disconnect while the bot is in mothion.

IMPORTANT: The wires on this sensor do not follow the normal color convention.
White = Ground
Red = 5V
Black = Signal

If you need a primer on soldering, here's a great intro.

Use a pair of wire snips to cut off a 3-pin wide segment of your headers.

Then you'll need to snip off the old JST connector. Strip all three wires and tin them.

Tinning the tip of your iron generously between each joint, connect each wire to one of the leads coming off the header.

The wires should be in BLACK-RED-WHITE order.

Do this for both PIR sensors.

Step 7: Mount the PIR Sensors

With shiny new connectors attached, the sensors are ready to go.

If you started printing the enclosure in Step 1, hopefully it's ready by now. Pull it out of the printer and clean off any jagged edges.

  1. Starting with one PIR sensor, feed the attached connector through the hole at the bottom of the enclosure.
  2. Line up the sensor with holes on one side of the box and attach the four screws from the outside. You'll need to apply some pressure from the inside to push the sensor out as far as possible.
  3. Repeat for the other side.
  4. Thread the connectors through the hole at the middle of the RedBot chassis. They should go all the way through the body of the robot.
  5. Lining up the enclosure with the holes on the bot, attach screws from the bottom. It's a bit of an awkward angle, and might require some elbow grease.
  6. Connect the two connectors to the main board. Use pin A0 for the left sensor and A1 for the right. Remember, BLACK is SIGNAL and WHITE is GROUND. The colors for these plugs will be opposite orientation of the plugs elsewhere on the board. Don't worry, you won't destroy your sensor if you get it backwards, but it won't work until you flip it around.
  7. Finally, snap on the top of the enclosure. It should stay pressure fit in place.

Step 8: Test PIR Sensors

The PIR (passive infrared) sensors we are using are basically the same sensors used in wildlife cameras and motion-activated porch lights. They register a pattern of heat energy emitted by objects in the environment (people, animals, lightbulbs, cars...). When that pattern changes rapidly, the sensor activates.

So let's test that they work.

  1. First, you'll want to copy both Arduino sketches from the Github directory for this project into your Arduino folder.
  2. Download all the files from the repo.
  3. Unzip the downloaded archive and open up the "arduino" directory
  4. Copy the contents of this folder into your Arduino folder (usually ~/Documents/Arduino)
  5. Open or restart the Arduino IDE
  6. Now "pir_test" should be visible in the File>Sketchbook menu. Open it.
  7. Upload this sketch just like you did for the earlier tests.
  8. You'll probably see one of the LEDs (D13) on the board flashing. This means the sensors are responding to movement.
  9. Stand still for 2 seconds. The light should go out.
  10. Wave or walk past the bot. The light should flash. This means it's working :)
  11. Try this on both sides of the bot, to make sure both sensors are working.

Step 9: Add Shyness!

One of the sketches you added to your Arduino folder is called "shy_drive", and it will allow the bot to respond to people. Open it in the Arduino IDE, and upload. If all goes well, you can plug in your bot, set it on the floor, and try to catch it!

Note that the bot will pause for 30 seconds when it first turns on to allow the sensors to warm up. It'll also wait 10 seconds after running away from any motion, so the sensor can recalibrate. You can fiddle with these constants in the sketch to change its behavior.