hey guys welcome to meworkstelugu in this we know about how to make a obstacle avoiding robot using Arduino
making video:
watch the below video to batter understand to do this project.
Object Following Robot components :
amazon links :- Arduino BuyNow
- L298N Motor driver BuyNow
- ultrasonic sensor BuyNow
- Breadboard and wires Bujnów
quartaz components links: - Arduino BuyNow
- L298N Motor driver BuyNow
- ultrasonic sensor BuyNow
- Breadboard and wires BuyNow
- Arduino BuyNow
- L298N Motor driver BuyNow
- ultrasonic sensor BuyNow
- Breadboard and wires Bujnów
quartaz components links:
If you want to buy Arduino components, I am giving my affiliate links. If you buy the components using my affiliate links, it will help to our channel and website growth. so do these small help.
obstacle avoiding robot circuit diagram:
connect the all the components as show in below circuit.
obstacle avoiding robot code :
int trigPin = 2; // trig pin of HC-SR04
int echoPin = 3; // Echo pin of HC-SR04
int revleft4 = 8; //REVerse motion of Left motor
int fwdleft5 = 9; //ForWarD motion of Left motor
int revright6 = 10; //REVerse motion of Right motor
int fwdright7 = 11; //ForWarD motion of Right motor
long duration, distance;
void setup() {
delay(random(500,2000)); // delay for random time
Serial.begin(9600);
pinMode(revleft4, OUTPUT); // set Motor pins as output
pinMode(fwdleft5, OUTPUT);
pinMode(revright6, OUTPUT);
pinMode(fwdright7, OUTPUT);
pinMode(trigPin, OUTPUT); // set trig pin as output
pinMode(echoPin, INPUT); //set echo pin as input to capture reflected waves
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH); // send waves for 10 us
delayMicroseconds(10);
duration = pulseIn(echoPin, HIGH); // receive reflected waves
distance = duration / 58.2; // convert to distance
delay(10);
// If you dont get proper movements of your robot then alter the pin numbers
if (distance > 19)
{
digitalWrite(fwdright7, LOW); // move forward
digitalWrite(revright6, HIGH);
digitalWrite(fwdleft5, HIGH);
digitalWrite(revleft4, LOW);
}
if (distance < 18)
{
digitalWrite(fwdright7, LOW); //Stop
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, LOW);
delay(500);
digitalWrite(fwdright7, LOW); //movebackword
digitalWrite(revright6, HIGH);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, HIGH);
delay(500);
digitalWrite(fwdright7, LOW); //Stop
digitalWrite(revright6, LOW);
digitalWrite(fwdleft5, LOW);
digitalWrite(revleft4, LOW);
delay(100);
digitalWrite(fwdright7, HIGH);
digitalWrite(revright6, LOW);
digitalWrite(revleft4, HIGH);
digitalWrite(fwdleft5, LOW);
delay(500);
}
}
If you have any doubts regarding to this project, contact me on Instagram or comment on YouTube video. I will help with my best.
0 Comments