Have you ever desired to construct a simple autonomous Arduino robot? I was inspired to build a basic Arduino robot in order to aid my understanding of the Arduino, the Arduino IDE, and the operation of ultrasonic sensors and motor drivers. And so, I have built such a robot with the intent to teach others as well.

Please note that throughout the course of this project, I changed the wiring a few times due to the fact that:

-Some wires were messily too long

-Some wires were not color coded accurately

-Some wires that needed PWM were not in the right Arduino pins

With this being said, following the wiring explanation in step 7 and the sketch comments will give you the correct wiring description.

*If you enjoyed this Instructable, please vote in the 'Make it Move' or the 'Robotic' contest*

Step 1: Necessary Materials

To begin the construction of this robot, only a few, low-cost materials are required. Now, I have not located the stores I have bought them at, due to the fact that I have purchased the following on sites such as Ebay and Amazon, in which sales end unpredictably, and others begin with the same abruptness. By purchasing at these stores, this robot can be made for around $40, provided ALL materials are bought at this time. Or else, the cost should be significantly less. Any who, the materials necessary are:

-An L298N motor driver

This motor driver is a duel-channel H-bridge circuit, which will provide the power for both motors, and the ability for both of the motors to run forwards and backwards. Enabled with PWM (Pulse-Width Modulation), the user can change each motor's speed to fit their needs.

-An HC-SR04 Ultrasonic sensor

This module is a sensor that detects objects at 'n' distance by preforming mathematical operations based on the reception time of the initial frequency it emits. (Waves are emitted, bounce off said object, and return to be processed by this unit)

-A Microcontroller

The brains of the robot. In this case, I am using an official Arduino Uno R3 microcontroller board.

-A power supply for the microcontroller and the motor driver

A 7-12 VDC power jack is needed to run the Arduino microcontroller, and the motor driver requires at least 5 VDC for this project. You can use the battery box in the RC car for both however, so no other power supply is needed.

-A cheap RC car

This is the platform in which to modify for our needs. Keep in mind that for our purposes, we will only be dealing with two DC motors, one for the rear wheels, and one to steer, which are found in cheap RC cars. More luxurious RC cars feature more complex systems such as servos, which can work, if one so desires, but will be forced to greatly modify the code and hardware intended for this basic project.

Step 2: Algorithm Development

In order to build this robot, I decided first to create a general idea of how it would respond to objects, with simplicity in mind, through the form of a flowchart. Above, you can see that if an object is equal to or less than n centimeters away, then the robot will reverse to the left for x seconds, or else it will drive for y seconds straight forward. With this principle, let's move on to the actual assembly.

Step 3: Chassis Preparation

On the RC car's underside, screws hold the exterior to the actual chassis. You will need to locate these screws and remove them. Try not to lose them for a further step. Once the exterior is removed, flip the chassis so it is in proper orientation. Note both motor casings, along with the main controller casing. (Typically in the direct middle of the chassis) You will need to play around with the visible screws and such in order to reveal the motor and controller casings.

Step 4: Controller Transplant

Begin by locating both wires of the rear motor, both wires of the front motor, and both wires of the battery box. There should be six total. Cut each wire as close to the controller as possible to make their leads as long as possible. Then, of course, strip the ends for easier use if necessary.

Step 5: Preparation and Motor Driver Installation

You will need to plan where you will mount each component. When you have found the location where you want to mount the Arduino, clear any obstruction to allow the microcontroller to lay flat. I have chosen directly above the battery box to mount mine.

Look for a good location for the motor driver as well. I chose the overhanging front-most edge to mount mine. I originally used twist ties, but have since then switched to screws. How I did this was by measuring out and drilling two screw holes in the plastic shelf, and then loosely secured the motor driver to the plastic shelf. I will give the pictures of this installation in the next step.

Step 6: Motor Driver Basic Tutorial

The pictures may not be as clear, so I will elaborate on each of the motor driver's 13 pins.

A motor driver is an electronic module that allows the polarity of two terminals to be reversed. When coupled with PWM, H-bridges can control both motor revolution direction, and speed.

What is PWM? (Pulse Width Modulation) PWM is a way of controlling the duration of an electronic pulse. The on-off cycle of the pulse is called a duty cycle. The larger the ratio of on to off results in a faster motor rotation. An analogy of this is found in the every day wind turbine. The quicker the pulse of wind on the turbine, the faster the revolution of the turbine.

There are 13 pins on the motor driver that you need to know:

Out 1: Motor A lead out

Out 2: Motor A lead out

Out 3: Motor B lead out

Out 4: Motor B lead out

5v: 5v input (unnecessary if your power source is 7v-35v, if the power source is 7v-35v then it can act as a 5v out)

GND: For ground. Have all of your grounds tied together; the Arduino, the battery box, and the motor driver.

12V/Power input: The power input. It can actually be from 5v-35v, but is just marked as 12v. The battery box will provide enough power, and the positive terminal of the battery box will go in here.

EnA: Enables PWM signal for Motor A

In1: Enable Motor A

In2: Enable Motor A

In3: Enable Motor B

In4: Enable Motor B

EnB: Enables PWM signal for Motor B

Step 7: Complete Installation and Wiring

This is the big step. Find and secure a location for the Arduino and the ultrasonic sensor. The pictures above show my process for mounting the components.

Now comes the wiring.

*I apologize, my wiring is inconsistent, as I changed it up and the colors many times due to changing circumstances and new discoveries. Resorting to the pictures for the wiring will NOT be clear, except for the Fritzing model above. I am going to write each wiring connection that must be made below as well. These descriptions are the latest, most accurate.*

The wiring is first from the motor driver:

ENA - Arduino digital pin 5

IN1 - Arduino digital pin 6

IN2 - Arduino digital pin 7

IN3 - Arduino digital pin 8

IN4- Arduino digital pin 9

ENB - Arduino digital pin 10

5V - Arduino 5V pin and ultrasonic sensor VCC pin

GND - Battery box negative terminal and Arduino GND. (I inserted the Arduino GND and the battery box negative terminal into the motor driver GND socket, and then tightened the screw carefully.12V - Battery positive pin

Now for the ultrasonic sensor:

GND - Arduino GND

ECHO - Arduino digital pin 4

TRIGGER - Arduino digital pin 3

VCC - Motor driver 5V

Once the wiring is done, pop back on the RC car's exterior if you choose, turn it on and have fun!

Step 8: Programming

I have the code in a file, I couldn't paste the text version so unfortunately you will have to download it. If you need further wiring hints, please read my sketch comments.

Step 9: You're Done!

Congratulations, you're done! If you have any problems or tips, please feel free to share.

The wiring has since been changed, but I have many pictures that document the wiring I used before I changed it, if you wanted to look at them.

*If you enjoyed this Instructable, please vote in the 'Make it Move' or the 'Robotic' contest*

<p>While uploading it shows the error</p><p>avrdude: ser_open(): can't open device &quot;\\.\COM1&quot;: The system cannot find the file specified.</p><p>Problem uploading to board. See <a href="http://www.arduino.cc/en/Guide/Troubleshooting#upload" rel="nofollow"> http://www.arduino.cc/en/Guide/Troubleshooting#up...</a> for suggestions.</p><p>This report would have more information with</p><p>&quot;Show verbose output during compilation&quot;</p><p>option enabled in File -&gt; Preferences.</p><p>Please help...</p>
Programe where can download
<p>Can you build it so that it can be controlled by a controller also? And can you also build it to have it go through a path or follow a line? Please tell me, since this is for a science fair.</p>
You definitely could, and using an RC car as a pre-built base model is a quick and durable platform to build on. Personally, I haven't implemented an RC or line following function, but that sounds like an awesome challenge for yourself :)
<p>i checked your video,i noticed that your front wheel is not turning totaly....why is that</p>
thanks <br>
<p>can we use a 9v instead of 7vdc jack?</p>
I'm not quite sure what you are referring to, but 9v for this situation should be good
<p>jumper wire.....m-m or m-f or f-f.</p><p>which is used?</p>
It really depends on your situation. Whichever wire type lets you make the connections is the right one.
<p>pls reply.............i am a nubee</p>
Going to revisit this with wifi control, and joystick control.
<p>I suppose you can link it up so you override it and control it via a 2.4Ghz controller:</p><p><a href="http://playground.arduino.cc/InterfacingWithHardware/Nrf2401">http://playground.arduino.cc/InterfacingWithHardwa...</a></p>
To solve the dragging problem, bend the pins back slightly
The headers are plastic, and thus too brittle to bend, I would think. But if it works for you, awesome.
I did this same kind of project with my son on his el cheapo RC monster truck that was collecting dust. Going to be modding the RC Nerf dart spider next! Great fun to be had taking my kids unused toys apart and adding arduinos!
Oh yea, its a lot of fun
Also, your sensors wires will meet an unfortunate death while dragging on the ground.
Good observation! I measured it before hand, so the four wires actually don't touch the ground. If you were to build an off road version, however, that would definetly be something to look at!
Thanks...love arduino instructables.<br>if interested i get my parts here &gt; <br>http://insanedeals4u.com/shopcategory/makers-crafters/<br> cheaper than most places.
Sweet, I'm excited to check it out! Thank you.
Thanks! And there is no voting button.
Thank you for looking! Mine wasn't approved yet yesterday, but has been accepted today.

About This Instructable




Bio: I'm currently a student, and playing around with ideas and plans for things to build keeps me preoccupied.
More by teknohawk:RC Car to Autonomous Arduino Robot Easy Dust Bomb! 
Add instructable to: