Object Avoiding Arduino Robot


Intro: Object Avoiding Arduino Robot

hello guys...

this is our 4th project..thats called object avoiding robot..

this one basically arduino based ic controlled by ultrasonic distance sensor..

An Ultrasonic sensor is a device that can measure the distance to an object by using sound waves. It measures distance by sending out a sound wave at a specific frequency and listening for that sound wave to bounce back. By recording the elapsed time between the sound wave being generated and the sound wave bouncing back, it is possible to calculate the distance between the sonar sensor and the object.

Step 1: Components

1:-arduino uno(Arduino UNO R3)

2:-ultrasonic distance sensor(hc-sr04)(Ultrasonic Sensor HC-SR04 Distance Measuring Transducer module for Arduino)

3:-two dc motors(REES52 BOSET BO Motor 100 RPM 2 Pieces + BO Wheel 2 Pieces + BO Motor Clamp with Screws 2 Pieces)

4:-jumper wires(Robo India JW-C3 Jumper Wire - 10 Male to Male + 10 Female to Female + 10 Male to Female)

5:-mini breadboard(KTC CONS Labs Nickel Plated 840 Points Bread Board or Solderless Piecesb Circuit Test Board, White)

6:-9v battery with jack

7:-l293d motor driver(Embeddinator's L293D Motor Driving Module)

8:-two wheels and caster wheel

9:-one chasis(Super Jumbo Chasis (Color May Vary))

*******(if you want to buy this components from amazon with low price,plz click on this components)

Step 2: Working Principle

Before going to working of the project, it is important to understand how the ultrasonic sensor works. The basic principle behind the working of ultrasonic sensor is as follows:

Using an external trigger signal, the Trig pin on ultrasonic sensor is made logic high for at least 10µs. A sonic burst from the transmitter module is sent. This consists of 8 pulses of 40KHz. The signals return back after hitting a surface and the receiver detects this signal.

The Echo pin is high from the time of sending the signal and receiving it. This time can be converted to distance using appropriate calculations. The aim of this project is to implement an obstacle avoiding robot using ultrasonic sensor and Arduino. All the connections are made as per the circuit diagram.

The working of the project is explained below. When the robot is powered on, both the motors of the robot will run normally and the robot moves forward. During this time, the ultrasonic sensor continuously calculate the distance between the robot and the reflective surface. This information is processed by the Arduino.

If the distance between the robot and the obstacle is less than 15cm, the left wheel motor is reversed in direction and the right wheel motor is operated normally. This will rotate the robot towards right. This rotation continues until the distance between the robot and any obstacle is greater than 15cm. The process continues forever and the robot keeps on moving without hitting any obstacle.

Step 3: Distance Sensor Connection


ultrasonic sensor

vcc is connect to +5v

gnd is connect to gnd

trig and echo pin is connect to arduino pin.

Step 4: Circuit Diagram


ultrasonic distance sensor:-



trig pin--------connect 5pin of the arduino

echo pin--------connect 6pin of the arduino.

and 8,7,4,and 3pin are connected to motor driver l293d

8pin of arduino connect..........2pin of l293d

7pin of arduino connect----------7pin of l293d

4pin of arduino connect------------10pin of l293d

and 3pin of arduino connect------15pin of l293d

Step 5: If You Used As L293d Ic

if you use l293d ic instead of l293d motor driver..

even its will be easy for connection.... l293d ic have 16pin... 1,8,9 and 16 pin connect to +5v.

and 4,5,12,13 pin connect to gnd...

input 1,2,3 and 4pin is connect to arduino pin..

output is connect to left motor and right motor..

input 1 and 2 is connect for left motor..

and input 3 and 4 is connect for right motor..

Step 6: Uploading the Code

here belew the code.....

just copy and paste to the arduino..and compile 1st then upload to arduino board.

const int trig = 5;
const int echo = 6; const int leftForward = 8; const int leftBackward = 7; const int rightForward = 4; const int rightBackward = 3;

int duration = 0; int distance = 0;

void setup() { pinMode(trig , OUTPUT); pinMode(echo , INPUT); pinMode(leftForward , OUTPUT); pinMode(leftBackward , OUTPUT); pinMode(rightForward , OUTPUT); pinMode(rightBackward , OUTPUT); Serial.begin(9600);


void loop() { digitalWrite(trig , HIGH); delayMicroseconds(1000); digitalWrite(trig , LOW);

duration = pulseIn(echo , HIGH); distance = (duration/2) / 28.5 ; Serial.println(distance);

if ( distance < 20 ) { digitalWrite(leftForward , LOW); digitalWrite(leftBackward , HIGH); digitalWrite(rightForward , HIGH); digitalWrite(rightBackward , LOW); delay(100); } else { digitalWrite(leftForward , HIGH); digitalWrite(leftBackward , LOW); digitalWrite(rightForward , HIGH); digitalWrite(rightBackward , LOW); }

Step 7: Applications

1:-Obstacle avoiding robots can be used in almost all mobile robot navigation systems.

2:-They can be used for household work like automatic vacuum cleaning.

3:-They can also be used in dangerous environments, where human penetration could be fatal.

Step 8: Result

so guys this link also help you to build this project easily...

follow this link and also our channel s_r tronics..

soooooo subscribe our channel to stay tuned with us..and likes also and do comment in inbox ....

next project coming soon...



    • Metalworking Contest

      Metalworking Contest
    • Audio Contest 2018

      Audio Contest 2018
    • Furniture Contest 2018

      Furniture Contest 2018