how to make obstacle avoidance robot using arduino

Obstacle avoidance robot using arduino, In this project Obstacle avoidance robot is designed using Arduino Uno R3. Obstacle avoidance robot is work with self intelligence if there is any hardle or obstacle in its way. It turn its direction automatically in case of any obstacle in its way. ultrasonic sensor is used to sense obstacle. The basic purpose of ultrasonic sensor is to measure distance from any obstacle in front of it. This distance measurement concept is used to change direction of robot when robot is at some distance close to handle or obstacle. HC-SR04 Ultrasonic sensor is used in this project.

HC-SR04 ultrasonic sensor for distance measurement :

ultrasonic sensor is distance measurement sensor which used ultrasonic waves to measure sensor. HC-SR04 ultrasonic sensor have ultrasonic waves transmitter and receiver which is used to measured distance with the help of reflection time of ultrasonic waves from transmitter to back into receiver. I have posted a separate article on Ultrasonic sensor interfacing with Arduino. I highly recommend you to read following article first. If you don’t know about utrasonic HC-SR04 sensor interfacing with Arduino Uno R3. because it is main part of Obstacle avoidance robot project. Check this article:

Ultrasonic sensor interfacing with Arduino and distance measurement

I hope that after reading above article, you know that how to measure distance using ultrasonic sensor and Arduino Uno R3. Now let’s proceed to next important part of this project that is how to interface two dc motors with Arduino Uno R3. It is very easy to interface Two DC motors with Arduino using L293D dc motor driver. Circuit diagram below shows how to connect dc motor and L293 motor driver with Arduino.

Circuit diagram of obstacle avoidance robot using Arduino :

Circuit diagram of obstacle avoidance robot using arduino is given below:

obstacle avoidance robot using Arduino

obstacle avoidance robot using Arduino

You should note that ultrasonic sensor have four pins voltage pin, ground pin , trigger pin and echo pin. L298 is a dc motor driver which is used to rotate motors in clock wise or anti clock wise direction. It is used to turn robot right, left, reverse and straight. Followings are main components of this obstacle avoidance robot using Arduino Uno R3.

Hardware components of  obstacle avoidance  robot:

  • Arduino Uno R3
  • 2 DC motors
  • HC-RS04 ultrasonic sensor
  • L298 Dc motor driver
  • Resistors

Code of  obstacle avoidance  project :

Code for this project is written using Ardino IDE. To downland code of this project check following link:

If your code doesn’t work you also have to add motor driver library in your arduino IDE software. To download motor driver click on following link:

If you have any issue with  obstacle avoidance  robot project. Feel free to comment on this post.

    We highly recommend EasyEDA for Circuit Design and PCB Prototype

Low Cost PCB Manufacturing & Fabrication Service - EasyEDA   

 PCB Prototype: Only $8.21 for 10pcs,100x100mm PCBs, 2-3 days' delivery    


  1. Sehar Habib May 7, 2015
    • Bilal Malik May 7, 2015
  2. Rishabh May 18, 2015
  3. Nipuna Rajapaksha September 22, 2015
    • Bilal Malik October 14, 2015
  4. MADHULIKA October 22, 2015
  5. Anupam February 7, 2016
    • Sam December 1, 2016
  6. Tom February 20, 2016
  7. HT February 24, 2016
  8. Pinky Katsaruware May 2, 2017

Add Comment

Subscribe to our blog to get updates in your email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,045 other subscribers