Introduction: Simple Object Avoider Robot the Using Actobotics Runt Rover Peewee Chassis and a Arduino

Picture of Simple Object Avoider Robot the Using Actobotics Runt Rover Peewee Chassis and a Arduino

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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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

Picture of 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!

Comments

a-dukes (author)2017-02-23

Hello!

Can anybody help? My rover is moving in circles, how do I make it go straight?

jscottb (author)a-dukes2017-02-23

Hi,

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.

Jorghe (author)2016-04-18

Hey jscottb,

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?

https://123d.circuits.io/circuits/1975406-controll...

The code is there, and I tried to explain every step.

Thank you!

ScottS68 (author)2016-03-07

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.

jscottb (author)ScottS682016-03-07

I PM the code to you. A note on it and the Adafruit V1 shield code...

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.

jscottb (author)ScottS682016-03-07

Send me a pm.

jscottb (author)2015-12-11

It's a PWM setting. See analogWrite on the Arduino page. 0 is off and 255 is full power.

jscottb (author)2015-12-05

The easiest way would to have a switch from the battery to the arduino/morot shield.

jscottb (author)2015-10-31

Great!

My reply was delete some how. I will repost here:

Vcc will be the pin on the right side of the tinker connector (see Step 6 for a picture showing the location) The GND pin on the tinker connector is the pin on the opposite side of the Vcc pin. The signal pin is the pin in the center of the tinker connector.

On the servo, you will connect the Brown wire to the GND on the tinker connector, the Red wire to the tinker connector Vcc. Then the Orange wire to the center pin (signal) of the tinker connector.

jscottb (author)2015-10-30

Vcc will be the pin on the right side of the tinker connector (see Step 6 for a picture showing the location) The GND pin on the tinker connector is the pin on the opposite side of the Vcc pin. The signal pin is the pin in the center of the tinker connector.

On the servo, you will connect the Brown wire to the GND on the tinker connector, the Red wire to the tinker connector Vcc. Then the Orange wire to the center pin (signal) of the tinker connector.

jscottb (author)jscottb2015-10-31

Great!

Nabaa (author)jscottb2015-10-31

It worked perfectly, thank you for the help.

jscottb (author)2015-10-30

The 5v (VCC) pins are the pins closest to the black female pin rail for the Arduino pins 0-SCL.

timk8 (author)2015-10-29

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.

jscottb (author)timk82015-10-29

Have a look here. 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.

timk8 (author)jscottb2015-10-29

Thank you so much for the quick reply. Would this be accurate?: I went into your code and replaced both- (#define ECHO_PIN 2;) & (#define TRIGGER_PIN 5;) with- (#define pingPin 7;) then i replaced any references to (ECHO_PIN) or (TRIGGER_PIN) with pingPin

It Compiled with no errors and I'll be able to test tonight. Again thank you so much!

jaspreet singh123 (author)2015-10-28

can u tell me the speed of your motors

They are 1:42 gear ratio and 140rpm.

The Evil Genius 945 (author)2015-09-16

pls i cant connect my pc to my arduino can you help me

What operating system are you on? What kind of Arduino do you have? You probably just need the USB driver for your computer.

santhosh santee (author)2015-05-29

hello i need code for this project.,pls help me

jscottb (author)santhosh santee2015-05-29

Hi, The code is in a zip file in Step 14.

Thanks

santhosh santee (author)jscottb2015-05-29

thank you sir

MichaelT33 (author)2015-05-18

"Once the library has been loaded, copy the below program and past it into the Ardriono IDE"

Where? I do not see any code below. Can you provide a url for the sketch?

jscottb (author)MichaelT332015-05-18

Hi,

The code the the bot is here in the Instrctable at:https://www.instructables.com/files/orig/FM3/1CO3/I... Step 14. Let me know if you have any issues.

Thanks.

ikanbane (author)2015-04-22

dstech (author)2015-04-20

Nice instructable! I'm working on 3d printing a base for a very similar robot right now! Keep up the good work.

jscottb (author)dstech2015-04-20

Thanks! I want a 3d Printer!!! :) Good luck with your bot!

hector.johnson.1614 (author)2015-04-14

what about ad fruit shield? is there any code for that?

Hi Hector,

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 the AFMotor.h 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.

regards

do you by any chance have it for version two?

My generic L298/L293 driver library should work. It has the same metods as does my Motor shield lib. See: https://github.com/jscottb/L29NDriver

BarakP (author)2015-04-14

You merciless human being, how could you trap such a helpless creature like that?!?!?! Don't you see he want to get out?

Awesome work! thamks for the sharing.

jscottb (author)BarakP2015-04-14

It was being a little too rumbustious! Give it fresh batteries and it wants to roam!

Thanks!

tomatoskins (author)2015-04-14

This is awesome! I remember making something like this back in high school. It was all programmed in BASIC however.

jscottb (author)tomatoskins2015-04-14

Thanks! It's a fun little bot!

About This Instructable

18,376views

171favorites

More by jscottb:ESP8266 HTTP IO ServerBoom and Gripper botWeb controlled rover
Add instructable to: