saravana Kumar
Published © Apache-2.0

How to make obstacles avoiding robot

The robot would have the capacity to detect obstacles in its path based on a predetermined threshold distance.

BeginnerFull instructions provided5 hours716
How to make obstacles avoiding robot

Things used in this project

Story

Read more

Schematics

Circuit diagram of obstacle avoiding robot

What we need in this project :-
1) arduino uno
2)ultrasonic sensor hc-05
3)mini breadboard
4)Dc motor
5)L298n motor driver
6)servo motor
7)cardboard
8)jumper wire (male and female)
9) arduino IDE

Code

Untitled file

Arduino
Here I share my project video. https://youtu.be/QJ_z5CzIfdk
int trigPin = 9;
int echoPin = 10;
int revright = 4;      //REVerse motion of Right motor
int fwdleft = 7;      
int revleft= 6;       
int fwdright= 5;       //ForWarD motion of Right motor
int c = 0;

void setup() {
  //Serial.begin(9600); 
   pinMode(5, OUTPUT);
   pinMode(6, OUTPUT);
   pinMode(4, OUTPUT);
   pinMode(7, OUTPUT);
   pinMode(trigPin, OUTPUT);
  pinMode(echoPin, INPUT);
  // put your setup code here, to run once:

}

void loop() {
  long duration, distance;
  digitalWrite(trigPin,HIGH);
  delayMicroseconds(1000);
  digitalWrite(trigPin, LOW);
  duration=pulseIn(echoPin, HIGH);
  distance =(duration/2)/29.1;
  //Serial.print(distance);
  //Serial.println("CM");
  delay(10);
 
  
  if((distance>20))
 {
  digitalWrite(5,HIGH);                               //       If you dont get proper movements of your robot,
   digitalWrite(4,LOW);                               //        then alter the pin numbers
   digitalWrite(6,LOW);                               //
   digitalWrite(7,HIGH);                              //
 }
 
  else if(distance<20)  
 {
   digitalWrite(5,HIGH);
   digitalWrite(4,LOW);
   digitalWrite(6,HIGH);                                  //HIGH
   digitalWrite(7,LOW);
                                            
 }
 
}

Credits

saravana Kumar
1 project • 0 followers

Comments