How to make obstacle avoiding robot using Arduino & Ultrasonic sensor ?

So you wanna build a robot which never hits anything; you’ve come to the right place ! It barely takes 15 minutes to do this ! So without wasting our time let’s learn how to make an obstacle avoiding robot !

Requirements :-

  1. Chassis OR any toy car.
  2. Arduino UNO/Mega.
  3. Ultrasonic sensor HC SR-04.
  4. 2 DC motors.
  5. 9V/12V 1A battery.
  6. Motor driver module L298.
  7. Jumpers.
  8. Single stranded wires.
  9. A pizza slice & a can of beer to celebrate ūüėČ

Procedure :-

So yes, I’m going to divide the whole making into 4 parts –

Connections of Ultrasonic sensor    →    Connections of L298N    →    Code    →    Testing

If you haven’t used or experimented before with the ultrasonic sensor, I would suggest you to get familiar with it first ! I have a detail tutorial on ultrasonic sensor HC SR-04 which will guide you throughout !

Here is detailed Tutorial on Ultrasonic Sensor HC-SR04 




 Connections :-

Connections for Obstacle avoiding robot

Connections for Obstacle avoiding robot

Connections of Ultrasonic sensor –

  1. VCC – VCC terminal of Arduino.
  2. GND РGND terminal of Arduino.
  3. Trigpin Рdigital pin 9 on Arduino.
  4. Echo pin –¬†digital pin 10 on¬†Arduino.

Connections of L298N –

  1.  +12V РPositive terminal of the battery.
  2. GND Рa)GND of Arduino   b)Negative terminal of battery.
  3. Input terminal 1 – Pin 4
  4. Input terminal 2 –¬†Pin 5
  5. Input terminal 3 –¬†Pin 6
  6. Input terminal 4 –¬†Pin 7
  7. Output terminal 1 – Positive of first motor.
  8. Output terminal 2 –¬†Negative of first motor.
  9. Output terminal 3 –¬†Positive of second motor.
  10. Output terminal 4 – Negative of second motor.

Coding :-

You may like –

Control LEDs with help of Android (in 5 mins)

&

Control LEDs with Voice commands (in 5 mins)




Testing :-

If the distance detected by the ultrasonic sensor is less than 25cm, then the bot will take a turn else, it will keep moving straight ! Simple… right ?

Well, here is a video tutorial which will make your job more easy !

Do I need to say this, NO… but anyway I will,

If you have any problem regarding connections or coding or during interfacing, all you have to do is comment down below OR contact me ūüôā I’ll very happy to help you

Leave a Reply

Your email address will not be published. Required fields are marked *