In this tutorial, you will learn how to build a robot car which will avoid the obstacles present in its path. The concept can be used and applied in various ways according to the conditions.

Pre-requisite: Arduino programming, bread board connections, ultrasonic sensor, basic electronics.

Components required:

Aruino Uno x 1

Ultrasonic sensor x 1

DC motors x 2

Jumper cables x 10

Chassis and wheels

9v battery

Arduino is an open-source electronics platform based on easy-to-use hardware and software. Arduino boards are able to read inputs - light on a sensor, a finger on a button, or a Twitter message - and turn it into an output - activating a motor, turning on an LED, publishing something online. You can tell your board what to do by sending a set of instructions to the microcontroller on the board. To do so you use the Arduino programming language (based onWiring), and the Arduino Software (IDE), based on Processing.

## Step 2: Theory & Data Collection of Ultrasonic

The robot works on four main aspects: data collection, data interpretation and modulation, logic designing and execution.

Data collection:
The data collection is done with the use of ultrasonic sensor. The ultrasonic sensor has a signal generator and a receiver. The signal generator generates an ultrasonic wave and transmits in the forward direction. The transmitted wave strikes any obstacle in its path and a huge part of it gets reflected. The receiver receives the reflected wave.

Data interpretation and modulation:
The obtained values from the ultrasonic sensor need to be calibrated in order to get a meaningful data (distance). The distance of the object is calculated on the basis of the time taken by the wave in the process of transmission, reflection and collection. The speed of the wave is known (equal to the speed of sound= 330m/s). Also the time taken is known (found by the ultrasonic sensor). We know that, Speed=distance/time Therefore distance= speed*time The obtained distance will be twice the distance between the sensor and the object. So by dividing the distance by a factor of 2, we will get the required distance.

## Step 3: Logic Designing & Execution

The main heart of the system is the arduino. The interpreted data (distance) is calculated in the previous step and now it needs to be used to design the logic of the system.

To avoid the obstacle in the path, a condition is put in the system which says: if the distance between the robot and the object gets below a certain level, turn the robot car into other direction and continue. This logic is applied to the system using basic C programming which is used in arduino.

We now have the conditions set up for the robot car. But it needs to be executed/implemented on the hardware. The hardware used is the DC motor.
Two motors are used in this process: left motor and right motor. To move the robot car forward, both the motors are turned on. To turn the robot car to avoid obstacle, one of the motor is turned off for a while, keeping the other motor on.

## Step 4: Code & Circuit Design

Here is code and the circuit design for the project.

## Step 5: Complete Robot

www.bipulgupta.com

<p>hello, i just wanted to ask you that is there a way to unplug it from the pc and connect a battery so that it can be tested on the ground if it's working like a real obstacle avoinding robot? let me know as fast as you can.</p>
code for this project is same for windows and mac, because code run in Arduino IDE.
Hi , I am beginner to Arduino. Can anyone tell me how to connect dc motors to arduino board?? use jumper wires or normal wires?? Thank you very much..
<p>the 9 volt battery is connecting only at the arduino ? not at the dc motors? thanks a lot!</p>
<p>Yes, 9 volt battery only connected to Arduino.</p>
<p>Thanks a lot. I have this <a href="http://www.ebay.com/itm/172383638336?_trksid=p2060353.m2749.l2649&ssPageName=STRK%3AMEBIDX%3AIT" rel="nofollow">http://www.ebay.com/itm/172383638336?_trksid=p2060...</a> </p><p>is the same dc motors as yours? Because something i have make wrong and i can not play...</p>
Yes this is same motor.
<p>Because it is my 1st project!!! i upload the photos of my connection. i do not understand if i make a mistake. i tried to reverse the motors also. Can you see them and propose me something please? Thanks a lot</p>
Can you give me the connection for battery
You can use this.
What is the material used
<p>For Which Part??</p>
That battery
<p>Nicely done :)</p>
Thanku..
<p>Thanks for the Ible, this will come in handy for a future project.</p>
<p>Welcome. :)</p>