HTML Image as link
Qries

Obstacle Avoiding robot using Arduino


Welcome to the Techatronic guys, So in this project, we will make an
Obstacle avoiding robot using Arduino and kit. do you know about the obstacle-avoiding robot? well, I am gonna explain to you what does it is and how does it work. basically,

Introduction

it is a robot that walks automatically with the help of an ultrasonic sensor. an ultrasonic sensor is used in many other mini-projects like Smart robots.

obstacle avoiding robot also known as the autonomous robot.
which takes the decision self. if there is something in front of the robot it will change
its path like a human.

so’ it is somewhere smart. it is the most popular project nowadays which is searched by most of the students nowadays. and everyone likes this robot.

in this project, you will also learn many things like how to use the ultrasonic sensor. and using the serial monitor also. we will discuss the code also.

A preview image of Obstacle avoiding robot can be different from your own.

Obstacle avoiding Robot

How does it work? / Working

In Obstacle avoiding robot,

there is a sensor that is known as the ultrasonic sensor. which has the capability to measure the distance in front of the sensor.

in the below paragraph we will know how does the sensor work. this obstacle-avoiding robot using Arduino Uno works as a distance measurer.

  • An ultrasonic sensor has two parts one is a transmitter and another is the receiver that is known as a trigger and echoes.
  • the trigger is the transmitter part and transmits the ultrasonic wave.
  • another part that is receiver an echo receive that transmitter ultrasonic waves transmitted from the trigger.
  • now we calculate that in how much time the ultrasonic waves return back to the receiver and divide by 2 because the time travel is double.

we can make many other mini projects for ece with this useful sensor.

ultrasonic sensor

we calculate the distance by the time and speed formula

distance = time X speed

of the ultrasonic wave = 340 m/s

l298n motor driver

Components Required for obstacle avoiding robot 

  1. Arduino NANO or Uno (any version)
  2. HC-SR04 Ultrasonic Sensor
  3. LM298N Motor Driver Module
  4. 5V DC Motors
  5. Battery
  6. Wheels
  7. Chassis
  8. Jumper Wires
Obstacle Avoiding robot using arduino component

this is a special Obstacle avoiding robot using Arduino to detect the distance here and there also.

the ultrasonic sensor is connected to the servo which rotates if there is any obstacle found in the path of the robot-like human. when we cross the road.

the robot walks straight and if it found any obstacle in the path it rotates its neck and compares the distance from the right and left then according to the distance it takes the decision.

for example,

it detects any obstacle in the path then it will stop and check right and left where is the maximum distance. so it will turn the right or left according to the maximum distance.

If you want to add a metal detector to this project that makes it a big project so you can learn about how to make a metal detector 

Learn 10+ basic activity & sensor interfacing with our Arduino ebook. Well explained program. And brief circuit diagram WhatsApp and email support. which will help you to learn basic electronics, Arduino Coding, Sensor interfacing with Arduino, Arduino, and much more. buy Arduino Ebook to learn https://techatronic.com/arduino-ebook/

Obstacle avoiding robot circuit diagram

obstacle avoiding robot circuit diagram

Fritzing Diagram

Fritzing-based diagrams help you make more clear connections still if you are stuck anywhere you can ask in the comment section.

Obstacle Avoiding robot using arduino circuit diagram

Connection Table

Arduino UNOServo Motor
PIN  3Signal Pin Orange Wire
VCCVCC Red Wire
GNDGND Black Wire
Arduino UNOUltrasonic Sensor
VCCVCC
PIN 5Trig
PIN 6Echo
GNDGND
Arduino UNOL293d Motor Driver
PIN 7IN 1
PIN 8IN 2
PIN 9IN 3
PIN 10IN 4
Arduino UNO9 Volt BatterySwitch
VIN PIN+ Positive 
 GNDTerminal 1
GND Terminal 2
L293d Motor Driver9 Volt BatterySwitch
+12 V PIN+ Positive 
 GNDTerminal 1
GND Terminal 2

Obstacle avoiding robot code:-

int duration=0;
long distance=0;
int firstduration=0;
long firstdistance=0;
int secondduration=0;
long seconddistance=0;

#include <Servo.h>
Servo myservo; 

int pos = 0;   

void setup() {
pinMode(5,OUTPUT);
pinMode(6,INPUT);
pinMode(7, OUTPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
 myservo.attach(3);
Serial.begin(9600); 
}
void loop()
 {
   digitalWrite(5, HIGH);
   delayMicroseconds(10);
   digitalWrite(5, LOW);
   delayMicroseconds(2);
   duration= pulseIn(6,HIGH);
   delay(100);
   distance=duration*0.034/2;
   Serial.println(distance);
   if(distance<=20)
    {
      digitalWrite(7, LOW);
      digitalWrite(8, LOW);
      digitalWrite(9, LOW);
      digitalWrite(10, LOW);
      delay(300);

      digitalWrite(7, LOW);
      digitalWrite(8, HIGH);
      digitalWrite(9, LOW);
      digitalWrite(10, HIGH);

      delay(350);
      digitalWrite(7, LOW);
      digitalWrite(8, LOW);
      digitalWrite(9, LOW);
      digitalWrite(10, LOW);

      myservo.write(0);
      delay(500);
      digitalWrite(5, HIGH);
      delayMicroseconds(10);
      digitalWrite(5, LOW);
      delayMicroseconds(2);
      firstduration= pulseIn(6,HIGH);
      delay(100);
      firstdistance=firstduration*0.034/2;
      int first = firstdistance; 
      Serial.println(firstdistance);

      myservo.write(90);
      delay(500);

      myservo.write(180);
      delay(500);
      digitalWrite(5, HIGH);
      delayMicroseconds(10);
      digitalWrite(5, LOW);
      delayMicroseconds(2);
      secondduration= pulseIn(6,HIGH);
      delay(100);
      seconddistance=secondduration*0.034/2;
      int second = seconddistance;

      Serial.println(seconddistance);

      myservo.write(90);
      delay(500);

if(first < second ) { digitalWrite(7, LOW); digitalWrite(8, HIGH); digitalWrite(9, HIGH); digitalWrite(10, LOW); delay(500); } else if(first >   second  )


{

    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, LOW);
    digitalWrite(10, HIGH);  
    delay(500);
  }
} 
else 
{
    digitalWrite(7, HIGH);
    digitalWrite(8, LOW);
    digitalWrite(9, HIGH);
    digitalWrite(10, LOW);
  }

}
Obstacle Avoiding robot using arduino

Video Sample

 
Spread the love, Share this post with friends

1 thought on “Obstacle Avoiding robot using Arduino”

Leave a Comment