How to Build an Arduino Robot on a Budget - The Woody Bot

The Arduino Uno with
 Adafruit Motorshield
I have had my Arduino for a while now and just couldn't decide on what I wanted to build with it. I've wired some simple electronic circuit to play with. I've messed with servos and all kinds of simple motor designs. But I finally decided I wanted to build a robot. I saw all kinds of chassis that were really cool and you can buy them all over the place. Yet I decided to start from scratch and use stuff I had lying around and spend as little money as possible. Hopefully you can do the same and have as good a time doing it as I have.

Arduino UNO R3 board with DIP ATmega328P

The first thing I noticed about a lot of the robots I saw online is that people were spending a hundred dollars or more on them to get very basic functionality. I wanted to spend no more than I already had from the Arduino and MotorShield purchase. The second thing I noticed was everyone was slapping everything together with no regard for how the poor little robot looked. I understand once you get it working your proud and have a feeling of accomplishment and want to share it, but I think a couple minutes and a clean looking robot are better combinations. Last but not least is the Robot should do something useful. I am not exactly sure what useful function my robot will be asked to do, but I will complete the chassis, get it performing well and decide then. The only thing I know for sure is that I want to incorporate a camera into the mix and have the bot interact with the surroundings with no intervention on my part. Should be fun.

The Woody Bot

Supplies
  • 1-Arduino - I used an Uno, your free to use whatever you have lying around. $22 from Amazon
  • 1-SainSmart L293D Motor Drive Shield - this is the same as the Adafruit Version 1 of this shield, they have just released the V2 and I have not checked it out at all. This project could easily be done using a couple motor drives instead, but I had the shield on the shelf. It will also allow me to add more servo controls later for a camera. I gave $12 for it on Amazon.
  • 2-Hobby Servo Motors-Modified to be 360 degree motors. No servo anymore. I had a couple old servo motors from my RC car racing days that had bit the dust. They wouldn't work with the RC controller but the motors were still good. One was an Airtronics and the other a Futaba. The conversion makes them a very useful bot drive motor with loads of torque. I will try and write a tutorial for this too. $0.00 (find a friend with burned out servos they will probably work for this) 
  • 2-wheels - I made mine from scratch using a hole saw and a drill press. This may be beyond your capability, which is fine. Wheels for servo motors don't cost a whole lot. $0.00
  • 1-Front Pivot Wheel -  I used an old pivoting wheel from a rolling storage bin. It works great and is free. $0.00
  • 1-Chassis - I made mine from a flat piece of 1/2" plastic like material I had laying around. this one could easily be made using plywood or any other material. $0.00
  • 1-Battery-  I decided upon and old Black and Decker VPX battery pack I had from an old drill. They are compact, 7v, last forever and I had chargers a for it. You can use anything you have available though. $0.00
  • 1-Switch-  I used a small 10amp micro toggle switch I had laying around. But any switch capable of the current draw the servos you use is fine. $0.00
  • Misc Screws -  depending on the materials you use you will need a couple dozen screws. $0.99
  • Zip ties - I am using Zip Ties to hold the battery in just because I want to. I may come up with a reusable design for a hold down in the future. $0.25
Total Price so far = $35.24. Not bad for a basic robot chassis that actually moves.

Chassis before wheel cutouts
Chassis Build
I decided on a flat 2 wheel chassis with independent drive.  Much like the 2 wheeled Smart Car chassis you find for $20 everywhere. But for those you have to buy the special geared wheel/motor combos and if they fail you buy them again. I am using 2 servos I modified to be 360 degree gear motors. Check out youtube for videos on hos to do this.

I started with a rectangular piece of plastic I cut 8 inches by about 6 inches. No reason, it was just a size I cut on the saw. I then cut the corners on the front off to give an impression of  a front end. I measured in 1" and back 4" and cut them off. If you look closely you
Basic Chassis Outline
will see I reused the waste pieces as mounts for the Arduino board. Setting the board at a n angle looks kewler I think. Next I cut 2 pieces 3" x 3/4" then split them 1" from one end on a 45 angle to create four servo motor mounts. I also notched out the back edge of the chassis to recess the wheels into the sides. This is optional and the wheels can be mounted outside the edge without cutting. That cut out is 9/16" deep by 3 1/4" long.  In hind sight I should  have made it 3/4" x 3" and then used the scrap pieces for the servo mounts. When I draw it up I may do that.

cutting the wheel
Wheels
Next I made 2 wheels using a 2 1/2" hole saw and a drill press. First I did it with the pilot bit in the hole saw, but I found out the diameter of the servos' gear mount was a little less than 1/4" so it wasn't tight enough. So I removed the pilot bit and clamped the material to the table and cut it using just the saw. The end result was a better wheel anyway since you have to cut really slow. I used a wheel I had cut with the pilot bit to mark the middle of the other wheels. Then I drilled a 3/16 hole clear through the wheel and the using a drill bit that was .225" I drilled
Bare wheel
a very shallow pilot hole to accept the servo mount. I then used a 3/4" course thread sheet metal screw to attach it to the servo. Before I am done I am planning on putting some traction on the outside of  the wheels. I found and old serpentine belt from an old plotter that looks like it will work wrapped around the outside. These wheels I found are pretty slick on smooth flooring.

Chassis Assembly
Servo attached to mounts
Servo Mounts
I chose the modified servos for a couple of reasons. First I had them already, duh. But mainly because of their low current draw. Both servos running simultaneously only draw about .150 amps or 150 Milli-Amps at 7 volts. Even under heavy load the current was really low. This is huge as far as battery life and  not smoking your motor shield and/or Arduino.

I found it easiest to assemble the servos and their mounts first. I just sat the mount in place and marked the servo holes with a pencil, pre-drilled a pilot hole and then screwed them together with sheet metal screws. The design is made with the drive shaft towards the front and the shorter motor mount towards the rear.

Align the back edge of the mount
with the back of the chassis
When ready align them on the bottom side of the chassis, get them straight and mark one edge with a pencil for a guide for drilling the mounting holes through the chassis bottom. The back edge of the motor mount should be very close to the back edge of the chassis.
Wheels and servos in place

Pay attention to where the other screws are located before you drill. 2 screws cannot occupy the same space, I promise.I found one screw in each mount was sufficient to make it solid. Repeat for the other side and your almost rolling.
Front wheel pivot pin sticking up too far


Front Wheel
The front wheel I selected is from a rolling storage bin. With 1" wheels it is about the perfect height to set the front level with the rear wheels. If your wheel is a different size, just adjust the diameter of the rear wheels to compensate. This wheel had a 1/4" shaft that was a little too long so I shortened it with a hack saw in the bench vise. Next I drilled a 1/4" hole centered 1 1/2" back from the front. You might need to glue or epoxy it in place. I have found
Rolling Chassis Ready for Electronics
this wheel  to be troublesome at times. I will be looking for a better one as I get time.

Battery
Zip ties for battery mounts
For a battery I decided on a Black and Decker VPX 7v battery pack. These are just what I had laying around but they are cheap and easy to come by on the web. Plus they fit great on this chassis. To mount it I made two small blocks 1" x 1/2" . Counter-sinked a hole in one end and used that to mount it to the chassis. I set the pack on the end of the chassis and flushed it up. Then set the blocks on the front edge of the pack and screwed them down. I then drilled a 3/16" hole through the other end of each mount all the way through the chassis to allow me to run a 2 zip ties around the pack and secure it in place. I will be working on a more re-usable mount in the future but for now this works. Check the pictures of the Arduino mount for positioning.

Arduino Mounts
Arduino mount from scraps
 on front of chassis
The mount I made for the Arduino was largely accidental. If you look at the very first picture in this article you will notice a mount I made for the Arduino out of Plexiglas, some motherboard standoffs and some stick on rubber feet. This is a general purpose stand to hold the Arduino while I was working on it. When I made that one I had intended on buying another Arduino so I made two of them. As chance would have it the mount was exactly the same length as the wedge shaped pieces I had cut off the front of the chassis. So I mounted the extra Plexiglas piece to the wedges and mounted them on the board. Make sure the USB port is up
Arduino and battery mounted
or you won't be programming it anytime soon. You will notice I mounted the standoffs on the plexi first then mounted it to the wedges. The Plexi is 2 1/2" x 3 1/4". Again pay attention to where the other screws are before you drill holes to mount it to the Chassis. At this point you have successfully completed the rolling chassis. Everything else is just wiring everything together.





Wiring
The wiring is going to be largely dependent on what other equipment your using. I chose a micro toggle
Servos run from underneath
 to M1 and M2
switch that fits perfectly on the back edge of the Arduino Plexiglas mount. I drilled a 1/4' hole in the center and mounted it there.  For my project I prefer to see things neat and clean. So I try to hide everything I can. With this in mind I drilled a 1/4" hole under the Arduino to allow me to run the servo wires up from underneath and wire straight into the M1 and M2 motor hookups. I also drilled 2 more 1/4" holes on either side of the arduino mount to run my power wires through.I ran the Black negative wire straight from the battery to the Grd lug on the motor shield.
The positive I ran from the battery to the Switch and then from the switch to the +M port on the motor shield. Make sure you leave the PWR jumper in place. The Arduino is powered by the battery through the Motorshield.

The battery connectors are just the basic crimp on spade connectors that I reshaped to point the wires where I wanted them to go. I did however solder the connectors to the wires. I prefer to solder all connections if possible but bread boards work fine too if they are strong enough for your current load.


Code
Go here for the Adafruit Motor Shield Libraries
Adafruit-Motor-Shield-library

The code I loaded to test everything out is just a series of movements to put it through its paces. It runs the Woody Bot forward for 2 seconds, rotates right and left for 2 seconds each way, then pauses for 2 seconds before repeating the loop in the other direction.  It is just the lines from the Motor Party Sketch modified for this test.It gives you an idea of how it will move and perform.

You may have to adjust your code for speed differences in the servos. Even identical servos can run at slightly different speeds which will give a curve to your path when the bot moves.

Next time I want to add a switch that will activate the sketch. This way it sets idle until I press the switch, runs through it and stops awaiting another press.

((((CODE BEGIN))))

#include <AFMotor.h> 
//Must have Adafruit MotorShield Library installed. 
//
//Check out wooodystime.blogspot.com for more info.
//
//Kevin Woodyard - Str8shotPhoto.com
//2013
 
AF_DCMotor motor(1, MOTOR12_64KHZ); 
// create motor #1, 64KHz pwm 
 
AF_DCMotor motor2(2, MOTOR12_64KHZ); 
// create motor #2, 64KHz pwm 

void setup() { 
 Serial.begin(9600); 
 // set up Serial library at 9600 bps 
 Serial.println("Woody Bot test!"); 
 
 motor.setSpeed(225); 
 motor2.setSpeed(225);
 // set the speed to 200/255 
} 
 
void loop() { 
 Serial.print("Move forward"); 
 
 motor.run(FORWARD); 
 motor2.run(FORWARD); 
 // turn both wheels forward, should go in a straight line.
 //adjust individual motor speed to correct for any curving in travel
 delay(3000); 
 
 Serial.print("Spin to the left"); 
 motor.run(BACKWARD);
 motor2.run(FORWARD);
 // Spin to the left for 2 seconds by counter rotating the motors
 delay(2000); 
 
 Serial.print("Spin to the right"); 
 motor.run(FORWARD);
 motor2.run(BACKWARD);
 // Spin to the right using the oposite rotations.
 delay(2000); 
 
 Serial.println("Pause"); 
 motor.run(RELEASE); 
 motor2.run(RELEASE); 
 // Release the motors and wait 2 seconds before starting again.
 delay(2000); 
 
// REPEAT OF first part of SKETCH with spins reversed
Serial.print("Move Forward 2"); 
 
 motor.run(FORWARD); 
 motor2.run(FORWARD); 
 // Turn on both wheels going forward 
 delay(3000); 
 
  Serial.print("Spin to the Right"); 
 motor.run(FORWARD);
 motor2.run(BACKWARD);
 // Spin to the right for 2 seconds by counter rotating the motors
 delay(2000); 
 
 Serial.print("Spin to the Left"); 
 motor.run(BACKWARD);
 motor2.run(FORWARD);
// Spin to the Left using the oposite rotations.
 delay(2000); 
 
 Serial.println("tack"); 
 motor.run(RELEASE); 
 motor2.run(RELEASE); 
 // stopped 
 delay(2000); 
} 












((((CODE END))))
 
Final Results
So here we have a simple starter chassis for an Arduino and an Adafruit Motor Shield. From here we can add anything we want, all kinds of sensors and code to make it do amazing things. I will warn you, your wife, girlfriend, mom or about anyone else that know nothing about robotics and Arduino's are NOT going to be impressed by this version of the Bot. They may smile and say "Nice job Honey", but you'll know they are less than amazed. But stick around for future articles and we will be upgrading and adding things that they WILL be impressed by. When this things chases the cat into the bedroom while barking like a dog, then we'll see who's impressed.

Good luck and Keep on wasting time.


Comments