Introduction: How to Make a Shy Robot
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:
- 1 x SparkFun Inventor's Kit for RedBot
- 2 x PIR Motion Sensors (you can substitute sensors from another source if you're comfortable reading a datasheet)
- 12 x #6 sheet metal screw, or smaller
- Female Headers
- or M-F jumpers, if you really don't want to solder anything
- Soldering supplies
- Soldering Iron
- Wire snips
- 3D Print of the PIR Tower (order from Shapeways, or print your own!)
How bout you just give me the files, OK?!
Alright sparky. You'll find everything you need on GitHub.
Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.
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:
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
- If you don't have the Arduino IDE installed, get it here.
- Download the RedBot Arduino library from this page.
- Unzip and drag the downloaded folder into your ~/Documents/Arduino/libraries directory to add it to the Arduino IDE.
- Plug RedBot into your computer with the included USB cable
- 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.
- Starting with one PIR sensor, feed the attached connector through the hole at the bottom of the enclosure.
- 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.
- Repeat for the other side.
- 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.
- 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.
- 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.
- 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.
- First, you'll want to copy both Arduino sketches from the Github directory for this project into your Arduino folder.
- Download all the files from the repo.
- Unzip the downloaded archive and open up the "arduino" directory
- Copy the contents of this folder into your Arduino folder (usually ~/Documents/Arduino)
- Open or restart the Arduino IDE
- Now "pir_test" should be visible in the File>Sketchbook menu. Open it.
- Upload this sketch just like you did for the earlier tests.
- You'll probably see one of the LEDs (D13) on the board flashing. This means the sensors are responding to movement.
- Stand still for 2 seconds. The light should go out.
- Wave or walk past the bot. The light should flash. This means it's working :)
- 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.