My first robot! I built this from the ground up, designing the platform, drive system, sensor array, and programming. I designed it with the idea it would be a flexible platform to experiment with and to be able to add accessories, like the blue LED headlights, which is what the small green breadboards are for. It has room for two battery packs - a 12v 1800mAh that drives both the Arduino board and the motor via the motor control shield; and a series of four 3.6v 280mAh surplus cell phone batteries I found on-line that can be arranged to run in series or in parallel as your power requirements demand. In this example they are in two groups in parallel of two batteries in series that power the headlights.
The Arduino, motor shield, battery pack, and various minor parts were all purchased off of E-Bay. The motor, gears, etc., were just parts from my garage salvaged from all manner of electro-mechnical devices over the years. And the wheels and some other parts were from surplus outfits such as American Science & Surplus ( http://www.sciplus.com/ ).
Alright, enough intro! Let's get to some of the details of how I built this.
Step 1: The Wiring Diagram.
Here's a Fritzing wiring diagram of how R3 is put together, and the Fritzing file itself is attached for those of you who use this awesome program. I couldn't find a Fritzing part for the motor shield from DK Electronics, so I took a picture of one and used that.
Step 2: The Body
The body is composed of a 1/4" plywood platform that is 4" x 7". There are a series of posts glued to the back that form enclosures to hold the batteries. In the front are two white blocks made from high density polyethylene from an old cutting board. A servo is attached to those with a couple of screws. The steering mechanism for the robot consists of a single caster I had laying around. The shaft of the caster goes through a hole in the front of the platform with washers top and bottom. I had a single armed servo horn that fit on top of the caster, which I epoxied to another single arm servo horn on the shaft of the servo motor. The white blocks were sized to fit so the servo was at the proper height for this particular caster. When the servo turns, it turns the caster and steers the robot.
On the underside at the back of the body are several blocks that hold the axles for the wheels. More on those in the next step.
On top of the plywood platform near the front are several nylon posts that will be used to attach the Arduino Uno R3 that is the brains of the robot. Behind that are a couple of green mini-breadboards I attached to experiment with accessories for the robot. You may notice a blackened area on one of them where one of my experiments went awry and started to melt the breadboard. It was a learning experience!
Step 3: The Drive Train
The drive train consists of a 12v Buehler gear motor that is attached to the back end of the robot using an L-bracket. I attached the L-bracket to the body of the robot so the motor slid tightly in between the body and the upward facing arm of the bracket. Then I put some epoxy along the seam where the motor touched the body, and that holds it securely in place. There is a large gear on the motor shaft that meshes with a smaller gear on the wheel axle so that when the motor spins, it drives the wheel. There are several wooden blocks attached to the body that the axle passes through to give it stability and hold it in place.
This part was definitely a learning experience. My first attempt was with a solid axle that attached to both wheels, but the robot wouldn't turn very well due to the fact that the rear wheels need to travel at different speeds for the robot to turn effectively. But of course that can't happen if they are tied together on the same solid axle. So then I sawed the axle in half so the motor just turns one wheel and the other wheel is free to turn at whatever speed it needs to. This works much better! But I had to add another support block to keep each half of the axle steady and secure.
The wheels are just some 2-1/2" hard plastic wheels I picked up surplus because I liked the color.
Step 4: The Sensor Array
R3 is an obstacle avoidance robot that uses an array of three ultrasonic sensors to interact with it's environment. At first I just used one sensor pointed straight ahead, but found that the angle of view for the sensor was pretty small. The robot would do fine if it came at something head on, but if it came at an obstacle at an angle, it wouldn't see it and would run into it. So I made an array of three sensors, one pointing straight ahead and one on each side pointing off at a 45 degree angle. That way the robot can "see" things it's approaching from an angle on either side.
I made the array out of more old high density polyethylene cutting board and epoxied the pieces together to form the 45 degree angles on the sides. For the middle piece, I also gave the robot some headlights. I had two lenses from old scanners that I drilled holes for above the ultrasonic sensor. Behind these I placed some blue LED's held in place by a piece of cardboard and some red duct tape. The leads for the LED's just poke through the cardboard in back.
I also drilled some small holes on the bottom of the center piece for supports to attach it to the robot. For the supports, I just used a couple of large finishing nails, cut the heads off, and then epoxied them into the holes. The pointy end of the nail now slides into a hole on the blocks that the steering servo is mounted on. This allows flexibility to remove and reconfigure the senor array, or to replace it with something altogether different.
Step 5: Assembly
The rest of the assembly is pretty straight forward and follows the Fritzing wiring diagram that I gave at the beginning. The Arduino Uno board goes on first, attached to the threaded nylon posts with some matching nylon screws. The screws were ever so slightly too big for the holes on the Arduino board, so I took a drill bit just a bit bigger than the holes and reamed them out a bit. Then the screws fit fine.
On top of that goes the motor control shield, which of course just plugs right into the Arduino board itself. On the corner of the motor shield that corresponds to the corner of the Arduino board where the analog pins are, there are three rows of 6 holes. One row is +5v, one row is ground, and one row corresponds to the analog pins on the Arduino. I used these for the ultrasonic sensors. I soldered 6 pin female headers into each row to make it easier to just use jumper wires to attach the sensors. Each sensor has one +5v pin, one ground pin, and then two data pins, one for trigger to send the ultrasonic "ping", and one that keeps track of the echo that comes back. So with three sensors and two data pins each, I used up all 6 analog pins. Of course you can use those pins as digital pins just by configuring them correctly in the software, which is what I did. The motor control shield requires it's own power source, especially if you're running a 12v motor like I am, since the Arduino board doesn't put out that much voltage. I attached a male DC barrel plug with a pigtail to the power screw terminals on the motor shield since that is what would interface most easily with the battery pack I had. And then the leads from the 12v motor attach to the motor screw terminals; in my case I used the terminals for motor 2. The shield will drive up to 4 motors.
The sensor array then slides on using the holes and mounting "nails" I described earlier. Then all the wires go on for the sensors. The ultrasonic sensors have male pins, so I used jumper wires with a female end to attach to the sensor and a male end to attach to the motor shield. Besides the 4 motor screw terminals, the motor shield also has two sets of three male pins that are for servo motors. I plugged the leads for my steering servo into the pins corresponding to servo 1 on the motor shield.
My batteries went on next. The blue battery pack in the photo has two leads on it - a male barrel plug that went into the power plug on the Arduino; and a female barrel connector that attached to the male barrel plug I attached to the power terminals on the motor shield. The battery pack also has a switch built right in, so once I connect everything up, I just use that switch to turn the robot on and off. The green, roughly triangular batteries are the surplus cell phone batteries. I have these arranged here so that two of them are in series, and then those two sets are in parallel. That way I have a 7.2v 560mAh battery pack that I use to power my two LED headlights. This is all wired on one of the small green breadboards, including a switch to turn the headlights on and off. The voltage is pretty darn close to what it should be for these particular LED's, so I didn't bother with any resistors, and it works great. I've attached another Fritzing diagram just for the headlights so you can get a better idea of how I did it.
Step 6: The Code
I've played around with various versions of the code for this project, trying to make it do different things. Attached is one version that works pretty well. It will cause the robot to back away from anything it approaches head on, and turn away from anything it approaches from an angle.
Step 7: Conclusion - Experiment and Have Fun!
There you have it - an Arduino based obstacle avoidance robot designed for flexibility and experimentation that works pretty well. I've included a short video here that shows how it functions. I've got rubber bands around the wheels here because these wheels are hard plastic and bit slippery. The rubber bands give it better traction.
If you have any questions, please ask - I'll do my best to answer. And if you've liked my Instructable, please vote for me!