Circuit Diagram

Obstacle Avoiding Robot using Arduino Circuit 1

Hardware Required

  • Arduino Uno  [Buy Here]
  • Ultrasonic Range Finder Sensor – HC – SR04  [Buy Here]
  • Motor Driver IC – L293D  [Buy Here]
  • Servo Motor (Tower Pro SG90)  [Buy Here]
  • Geared Motors x 2 
  • Robot Chassis  [Buy Here]
  • Power Supply 
  • Battery Connector
  • Battery Holder

Component Description

Arduino Uno

Arduino Uno is an ATmega 328p Microcontroller based prototyping board. It is an open-source electronics prototyping platform that can be used with various sensors and actuators.

Arduino Uno has 14 digital I/O pins out of which 6 pins are used in this project.

Arduino Uno Board
HC – SR04

It is an Ultrasonic Range Finder Sensor. It is a non-contact based distance measurement system and can measure the distance of 2cm to 4m.

Ultrasonic Sensor


It is a motor driver which can provide bi-directional drive current for two motors. 

Servo Motor 

The Tower Pro SG90 is a simple Servo Motor which can rotate 90 degrees in each direction (approximately 180 degrees in total).  

Design of Obstacle Avoiding Robot using Arduino

Arduino is the main processing unit of the robot. Out of the 14 available digitals I/O pins, 7 pins are used in this project design.

The ultrasonic sensor has 4 pins: Vcc, Trig, Echo, and Gnd. Vcc and Gnd are connected to the +5v and GND pins of the Arduino. Trig (Trigger) is connected to the 9th pin and Echo is connected to the 8th pin of the Arduino UNO respectively. 

A Servo Motor is used to rotate the Ultrasonic Sensor to scan for obstacles. It has three pins namely Control, VCC and GND. The Servo Control Pin is connected to pin 11 of Arduino while the VCC and GND are connected to +5V and GND.  

L293D is a 16 pin IC. Pins 1 and 9 are the enable pins. These pins are connected to +5V.  Pins 2 and 7 are control inputs from microcontroller for the first motor. They are connected to pins 6 and 7 of Arduino respectively.

Similarly, pins 10 and 15 are control inputs from microcontroller for the second motor. They are connected to pins 5 and 4 of Arduino. Pins 4, 5, 12 and 13 of L293D are ground pins and are connected to Gnd.

A first motor (consider this as the motor for the left wheel) is connected across the pins 3 and 6 of L293D. The second motor, which acts as the right wheel motor, is connected to 11 and 14 pins of L293D.

The 16th pin of L293D is Vcc1. This is connected to +5V. The 8th pins are Vcc2. This is the motor supply voltage. This can be connected anywhere between 4.7V and 36V. In this project, pin 8 if L293D is connected to the +5V supply. 

NOTE: The power supply to the Motor Driver i.e. Pins 1 (enable 1), 8 (VCC2), 9 (enable 2) and 16 (VCC1) should be given separate power supply.

Motor Driver boards are available with an onboard 5V voltage regulator. A similar one is used in the project. 

If the above Circuit Diagram of the Obstacle Avoiding Robot is unclear, the following image might be helpful. 

Obstacle Avoiding Robot using Arduino Circuit 2


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

Using an external trigger signal, the Trig pin on the 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 calculates 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 Robot stops and scans in left and right directions for new distance using Servo Motor and Ultrasonic Sensor. If the distance towards the left side is more than that of the right side, the robot will prepare for a left turn. But first, it backs up a little bit and then activates the Left Wheel Motor in reversed in direction. 

Similarly, if the right distance is more than that of the left distance, the Robot prepares right rotation.  This process continues forever and the robot keeps on moving without hitting any obstacle.


  • As the project is based on Arduino, the programming is very easy and can be easily modified.
  • Doesn’t require the Arduino Motor Shield.
  • When using a 9V battery, at least 2 such batteries are needed to power the robot. It is better to use 2 9V batteries (one for Arduino, Ultrasonic sensor, Servo Motor and the other one for L293D and motors).
  • The Ultrasonic sensor should not be connected directly to the power supply as it might affect the normal performance.
  • Instead of the ultrasonic sensor, an IR transmitter-receiver pair can also be used.


  • Obstacle avoiding robots can be used in almost all mobile robot navigation systems.
  • They can be used for household work like automatic vacuum cleaning.
  • They can also be used in dangerous environments, where human penetration could be fatal.

By the end of this article, you came to know about designing an obstacle avoidance robot and the code to run the device. To your surprise, we have also provided Robot vacuum cleaners that make use of anti-collision and obstacle avoidance sensors. Just with a click, know more about the Robot Vacuum Cleaners that has amazing features.

Earlier the robots move in all directions as per the commands are given to it. Later they came to know that it got stuck when there is an unexpected obstacle in front of it. So they made extreme research work and come with the Obstacle avoidance Arduino robots.

You came to know about its applications, working, and the hardware parts required assembling. You have attempted it many times and didn’t get the result or would like to get from other sources. Then the Arduino Robot Kits is for you.

These kits are a great solution for beginners, and the engineers to build their knowledge in Arduino and Robots by designing cool projects. It has a manual to guide assembling procedure, working theories and project designs.


Please enter your comment!
Please enter your name here