There are many ways to build a robot, from scratch a kit, a prebuilt system or combination of any of these methods. The path we will take here will be mostly from a kit and other items such as an Arduino controller, motor driver and sensors from eBay or other vendors.

The chassis kit I use for this project is the Peewee which comes from Actobotics, from their Runt rover line but any two wheeled small robot kit will work fine as well for this project. I chose the Peewee because it's small, inexpensive, durable, has lots of mounting options and is easy to put together. To assemble it you need no tools and can follow the video supplied by the manufacture. It can be assembled in under 10 minutes or less by most persons.

Step 1: The Software Needed

Things you will need to download:

Step 2: Hardware Bill of Materials

Parts you will need are as follows:

After you have purchased, collected and downloaded everything thing you're ready to start with the build!!!

Step 3: Assembly - the Chassis

First assemble chassis following the instructions included with the chassis or video. After finishing you should have something like the image.

Step 4: Adding the Arduino and Motor Shield

Next attach the Arduino controller board and motor shield together then place them into the clip holder or onto your screw mounts (if you are using another type chassis). After you're done with that it should look something like this.

Step 5: Wiring - the Motors

Now you can start hooking up wire connections. First connect the motor wires to the motor output terminals on the motor shield. For this bot the left side motor (with the rear of the bot facing you) will be connected to the ‘A’ channel. The black wire is in the first terminal and the red the second terminal. This leaves the right motor going to channel ‘B’, with with black again on the first terminal and red in the second. See pic for more details.

Step 6: Wiring - the Ultrasonic Sensor

Next connect the HC-SR04 up by connecting VCC to one of the left pins of the tinker connector on the motor shield. The 5v (VCC) pins are the pins closest to the black female pin rail for the Arduino pins 0-SCL. After this is done, connect the GND pin of the sensor to the right pin of the tinker connector. After that, connect the Echo line to the Arduino’s pin 2. You can either connect it to the middle pin (the pin between VCC and GND) on the tinker connector for pin 2 or on the black rail for pin 2. Now connect the Trigger line to the Arduino’s pin 5. Again you can choose to either connect it to the middle pin (the pin between VCC and GND) on the tinker connector for pin 5 or on the black rail for pin 5.

Step 7: Wiring - the Servo

Now you can hook up the servo. Connect the GND wire (usually black or brown, but opposite side of the white or orange wire. Place it on one of the tinker connector gnd pins. Then connect the servos center wire to a tinker connectors VCC. Finally signal wire (white or orange) to the center pin for the tinker connector for pin 6.

Step 8: The Sensor Mount

To place the servo on the bot, cut a small piece of double sided sticky tape and stick on the bottom of the SG90 servo. Take the servo and place it in the center of the two holes at the front of the chassis. NOTE: If you have two screws that fit the servo and chassis holes that are long enough, you can use those :-) Take the plastic soda bottle top and carefully cut a slit across it (see picture below), wide enough for the sensor board to slide into. Use a little hot glue or rubber cement on both sides to hold it in place. Now take the servo cross attachment horn “+” and glue it to the top side of the bottle cap. You can also drill a small hole with a small drill bit or even a little screw driver into the center of the top to help secure the mount even better on the servo with a screw.

Once you have the sensor ready to mount on the servo,
place it on the horn and turn the servo slowly and VERY gently all the way in one direction, then the other to figure out the middle point. Once you think you have it, press the sensor on without the screw until you are sure it's in the correct position.

Step 9: Wiring RECHECK!!!

Now... Recheck all the wiring!

  • Left Motor Black wire --> Motor sheild 'A' first teminal
  • Left Motor Red wire --> Motor sheild 'A' second teminal
  • Right Motor Black wire --> Motor sheild 'B' first teminal
  • Right Motor Red wire --> Motor sheild 'B' second teminal
  • HC-SR04 VCC --> Motor sheild tinker connector pin for VCC (pin closest to the Arduino pin rail)
  • HC-SR04 GND --> Motor sheild tinker connector pin for GND (pin furtherest away from the Arduino pin rail)
  • HC-SR04 ECHO --> Arduino’s pin 2 (either on middel pin of the tinker connector for pin 2 or the Arduino’s pin 2 on the rail)
  • HC-SR04 TRIG --> Arduino’s pin 5 (either on middel pin of the tinker connector for pin 5 or the Arduino’s pin 5 on the rail)
  • Servo GND (Black or Brown) --> Motor sheild tinker connector GND pin
  • Servo VCC (Red) (servo center wire) --> Motor sheild tinker connector VCC pin
  • Servo signal wire (white or orange) --> Motor sheild center pin for the tinker connector for pin 6.

Step 10: It's Time to Load the Code

With the wiring checked and rechecked, It's time to load the code.
Follow the instructions on the Arduino site on how to install the Arduino IDE. After the IDE is installed, you can next install the Motor Driver library. Do this by down loading the zip file and extracting it to your Arduino libraries folder or by following these instructions on how to add a library. Once the library has been loaded, copy the below program and past it into the Ardriono IDE. Connect your PC and Arduino up with the USB cable. Now choose the board from the Tools->Board menu in the IDE, Uno for this project (choose the board you have if different from Uno) Now from Tools->Port menu, pick your com port. After this is done, click the upload button. If all went well, the code was loaded, if not see here for help on the IDE and related issues.

Step 11: Connecting the Batteries

After the code has been loaded on to the controller, you can hook the battery pack up. If you are using a battery holder (with no batteries at this point), hook the black wire to the motor shield motor power in GND and the red to VIN. If you have a li-po or li-ion, you can use jumper wires as pictured to connect the battery, again black to GND and red to VIN.

Step 12: Powering On!

As you make the last connection, you may want to hold the bot in one hand whilst doing it or it may get away from you! I do have a 30 second delay at startup to give you some time for adjustments. Once the bot powers on, the sensor servo is set to the neutral position (angle 90) and then the 30 second delay begins. At this point if you need to reposition the sensor mount, you can do so. After the delay has completed, the bot will move forward if all the connections were right and made well. If not, recheck them again and make any corrections needed. If they are right and the sensor looks centered enough, you can screw the bottle top to the servo using one of the servo screws that came with the servo. If the robot is moving backwards or turning instead of going forward at first move, switch the motor wires on the sheild terminals until they are correct (you may have to play around with it some)

Step 13: Your Bot and Batteries

One of the most common mistakes and problems for beginning robot builders is battery choice. Most pick batteries they are familiar with like 1.5V ‘AA’ or 9V alkaline or “Super duty” batteries. These are cheap and easy to get. However are not the correct choice though for powering your bot!!! A robot has a computer, motors, motor drivers and sensors that all need power. ‘AA’, 9v alkaline or the like will NOT supply enough power for them all.

In this day and age you have a lot of different battery types to choose from; NiCAD NiMH, Li-ion and Li-po just to name a few. They come in many shapes and voltage/mah sizes. For this robot or most any beginner bot I highly recommend using Li-ion 7.4v packs. They are relatively inexpensive for the power they give and easy to work with. For a good 7.4v pack you will expect to pay at least 10$USD. You will also need a charger, and one can be had for near the same price as the batteries.

Now you could go with NiCAD or NiMH 1.2v ‘AA’ size rechargeable, and you will need at least 5 of them to get the same voltage as 4 normal ‘AA’s. This is not a big issue since you can get 5 slot ‘AA’ holders. Rechargeable’s are easily found at most department, sporting or electronic stores. Buying 5 batteries and a charger may be around the same cost as the Li-ion option.

You can find both batteries and chargers on eBay, Adafruit, ServoCity, Sparkfun or hobby sites like HobbyKing and many other places. Do shop around!

Final battery note... Picking a battery for your bot may seem trivial, but it will weigh a lot more in it's performance than any thing else at first!!

Step 14: The Code...

Step 15: The Little Bot in Action!

The video above shows the bot in action. The code running on the video bot has close object reaction distances (2cm) and driving faster to show the maneuverability of the bot. It just wants to run free like other little robots!

<p>Hello!</p><p>Can anybody help? My rover is moving in circles, how do I make it go straight?</p>
<p>Hi,</p><p>I would check the motor wiring, you may have one side backwards. You could try switching one sides motor wires and see if that changes anything. </p>
<p>Hey jscottb,</p><p>I am currently on a project that involves servo functions, your tutorial really helped me understand better, however, i've been struggling with the servo you are using, it seems that it doesn't get the signal. There are two buttons, one to get it to 0 degrees and another to 180 degrees, but the micro servo doesn't work, would you mind telling me if I'm doing something wrong?</p><p><a href="https://123d.circuits.io/circuits/1975406-controlling-2-servos-with-buttons/" rel="nofollow">https://123d.circuits.io/circuits/1975406-controll...</a></p><p>The code is there, and I tried to explain every step.</p><p>Thank you!</p>
<p>I am trying to create the bot in your instructable for my classroom. I am using SainSmart L293D Motor shields because those are the only ones I have access to in quantities I can use with my students. Is there any way I can make your code work with this shield? I am relatively new to this, but learning fast. Any pointers would help.</p>
<p>I PM the code to you. A note on it and the Adafruit V1 shield code...</p><p>The V1 code uses extra timers and eats up a lot of GPIO's. The ultra sonic sensor will have to be moved to the analog pins. I has the code adjusted for those pins, but you may have to play around with it. Let me know if you need anything else. </p>
<p>Send me a pm.</p>
<p>Can somebody please tell me how I would modify the code so that I can use the 3 Pin RadioShack Ultrasonic sensor that I have? All I can find is the code for the 4 pin.</p>
<p>Have a look <a href="https://www.arduino.cc/en/Tutorial/Ping">here</a>. That is code for the 3 pin sensor (the Parallax Ping and Radio Shack). Just change the robots code that reads the 4 pin sensor to do the digitalWrite's and pulsein to one pin instead of two. </p>
<p>Thank you so much for the quick reply. Would this be accurate?: I went into your code and replaced both- (#define ECHO_PIN 2;) &amp; (#define TRIGGER_PIN 5;) with- (#define pingPin 7;) then i replaced any references to (ECHO_PIN) or (TRIGGER_PIN) with pingPin</p><p>It Compiled with no errors and I'll be able to test tonight. Again thank you so much!</p>
<p>can u tell me the speed of your motors</p>
<p>They are 1:42 gear ratio and 140rpm.</p>
<p>pls i cant connect my pc to my arduino can you help me </p>
<p>What operating system are you on? What kind of Arduino do you have? You probably just need the USB driver for your computer.</p>
<p>hello i need code for this project.,pls help me</p>
<p>Hi, The code is in a zip file in Step 14.</p><p>Thanks</p>
<p>thank you sir</p>
<p>&quot;Once the library has been loaded, copy the below program and past it into the Ardriono IDE&quot;</p><p>Where? I do not see any code below. Can you provide a url for the sketch?</p>
<p>Hi,</p><p>The code the the bot is here in the Instrctable at:<a href="https://www.instructables.com/files/orig/FM3/1CO3/I8CW5WSU/FM31CO3I8CW5WSU.zip" rel="nofollow">https://www.instructables.com/files/orig/FM3/1CO3/I...</a> Step 14. Let me know if you have any issues.</p><p>Thanks.</p>
<p>Nice instructable! I'm working on 3d printing a base for a very similar robot right now! Keep up the good work. </p>
<p>Thanks! I want a 3d Printer!!! :) Good luck with your bot!</p>
<p>what about ad fruit shield? is there any code for that?</p>
<p>Hi Hector,</p><p>If you are talking about the the original Adafruit motor shield, then it would not be too hard to convert the code I have to use it. The Adfruit motor shield V1 code is what I tailored my Motor driver code after. You would just have to change the include to th<strong>e AFMotor.h</strong> and the create of the motor objects to what the Adafruit library needs (see their examples) I did not use it for this robot due to that shield limiting the IO pins selection you have. </p><p>regards</p>
do you by any chance have it for version two?
<p>My generic L298/L293 driver library should work. It has the same metods as does my Motor shield lib. See: <a href="https://github.com/jscottb/L29NDriver" rel="nofollow"> https://github.com/jscottb/L29NDriver</a></p>
<p>You merciless human being, how could you trap such a helpless creature like that?!?!?! Don't you see he want to get out?</p><p>Awesome work! thamks for the sharing.</p>
<p>It was being a little too rumbustious! Give it fresh batteries and it wants to roam!</p><p>Thanks!</p>
<p>This is awesome! I remember making something like this back in high school. It was all programmed in BASIC however.</p>
<p>Thanks! It's a fun little bot!</p>

About This Instructable



More by jscottb:ESP8266 HTTP IO Server Boom and Gripper bot Web controlled rover 
Add instructable to: