Introduction: Obstacle Avoiding Robot

In robotics , obstacle avoidance is the task of satisfying some control objective subject to non- intersection or non-collision position constraints . It has a sonar sensor which are used to sense the obstacles coming in between the path of robot . It will move into the best direction and avoid the obstacle which is coming in its path. By adding sensor in this robot one can simply collect data from the environment .

It can perform more precisely than many robots even in a small place .

Step 1: Know How This Thing Works

You can see the most updated informations from my github repository.

Step 2: Gather Things :

An arduino uno or any arduino (I have used arduino uno)

A sonar sensor (HC-SR 04)

A few jumper wires

2 resistor (220 ohms)

L298 dual motor control driver

A battery

A chassis (Normally includes other needed components )

2 gear motors

Step 3: Connect All Parts :

Sonar connections :

Vcc – 5 Volt

GND – GND

Trig – Arduino 4

Echo – Arduino 5


Motor driver :

EnB – 220 ohms resistor - 5 Volt (Motor Driver – to control speed) (EnB to enable through a 220 ohms resistor)

EnA – 220 ohms resistor - 5 Volt (Motor Driver – to control speed) (EnA to enable through a 220 ohms resistor)

IN1 – Arduino 9

IN2 – Arduino 8

IN3 – Arduino 7

IN4 – Arduino 6

GND – Arduino GND

Vcc – Arduino Vin

Now connect motors with driver via Motor-A and Motor-B port .

Step 4: Upload Code :

Lets upload the code into the heart . It’s the beauty

of the robot . If you want you can modify pins or code . Such as – modifying speed , minimum distance from object , duration of running in any direction. Useful comments are given in the code to understand more easily .

(No extra driver or header file needed)

I have uploaded the file , you also can get the code here (to see more updates)

Step 5: Final Stage :

Plug in the battery and enjoy !

You can see my working robot1 , robot2 .

If you find any bug let me know in the comment section
and if you can fix that you can modify code here or simply give in the comment section.

Thank You .