Posts

Showing posts from June, 2021

Object avoiding robot car

Image
//hrrobotics Object avoiding robot car int trigPin = 9; //sensor pin int echoPin = 8; int revleft4 = 10; // Motor Pins int fwdleft5 = 11; int revright6 = 12; int fwdright7 = 13; long duration, distance; void setup() { 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 O/P To Transmit Waves pinMode(echoPin, INPUT); //Set Echo Pin As I/P To Recieve Reflected Waves } void loop() { digitalWrite(trigPin, LOW); delayMicroseconds(2); digitalWrite(trigPin, HIGH); // Transmit Waves For 10us delayMicroseconds(10); duration = pulseIn(echoPin, HIGH); // Recieve Reflected Waves distance = duration / 58.2; // Get Distance delay(10); if (distance > 30) // Condition For Absence Of Obstacle { digitalWrite(fwdright7, HIGH); // Move Forward digitalWrite(revright6, LOW); digitalWrite(