Obstacle Avoiding Arduino Car
by Mr innovative in Circuits > Arduino
6212 Views, 55 Favorites, 0 Comments
Obstacle Avoiding Arduino Car
Hello everyone I am sharing here what I make a Obstacles avoiding arduino car. I used here easily available material, these robo continue run forward until and unless any obstacle came in front of car so let's see and make ......
Materials Required
1-Arduino uno board
2- HC-SR04 Ultrasonic sensor
3- 75 RPM L shape gear motor 2 nos.
4. Old CD drive case for chassis.
5. Bread board
6. Wheels
7. Jumper wires
8. Tools for work
2- HC-SR04 Ultrasonic sensor
3- 75 RPM L shape gear motor 2 nos.
4. Old CD drive case for chassis.
5. Bread board
6. Wheels
7. Jumper wires
8. Tools for work
Assembly
First we assemble our all components, I share some pic to visualize how to assemble a car, you can do as you want just be sure ultrasonic sensor must be at most far front portion of your car, to avoid unnecessary disturbance in sensor reading.
Wiring and Code
so now time to wire your car.
please read pic cearfully. make connection as shown in pic, I hope each and every wiring detail is covers in pic if any doubt pls feel free to contact.
must check your wiring before applying power....
now its time to upload code to give life to your car..
/* code for obstacles avoiding arxuino car
*/
#define ECHOPIN 7
#define TRIGPIN 8
void setup(){
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
}
void loop()
{
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);
float distance = pulseIn(ECHOPIN, HIGH);
distance = distance/58;
if (distance >= 30)
{digitalWrite(11, HIGH);
digitalWrite(10, HIGH ;);
digitalWrite(9, LOW);
}
else
{digitalWrite(11, HIGH);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay(2000);
}
Serial.print(distance);
Serial.println(" cm");
delay(200);
}
// code end
so this is code upload this to arduino board and let your car to move, in this code I keep safe distance of 30 cm you can modify as per your need.
so thats it I hope I provide much details , if some thing skip pls ask let do some thing creative and share what you make ....
thanks.
please read pic cearfully. make connection as shown in pic, I hope each and every wiring detail is covers in pic if any doubt pls feel free to contact.
must check your wiring before applying power....
now its time to upload code to give life to your car..
/* code for obstacles avoiding arxuino car
*/
#define ECHOPIN 7
#define TRIGPIN 8
void setup(){
Serial.begin(9600);
pinMode(ECHOPIN, INPUT);
pinMode(TRIGPIN, OUTPUT);
pinMode(11,OUTPUT);
pinMode(10,OUTPUT);
pinMode(9,OUTPUT);
}
void loop()
{
digitalWrite(TRIGPIN, LOW);
delayMicroseconds(2);
digitalWrite(TRIGPIN, HIGH);
delayMicroseconds(10);
digitalWrite(TRIGPIN, LOW);
float distance = pulseIn(ECHOPIN, HIGH);
distance = distance/58;
if (distance >= 30)
{digitalWrite(11, HIGH);
digitalWrite(10, HIGH ;);
digitalWrite(9, LOW);
}
else
{digitalWrite(11, HIGH);
digitalWrite(10, LOW);
digitalWrite(9, HIGH);
delay(2000);
}
Serial.print(distance);
Serial.println(" cm");
delay(200);
}
// code end
so this is code upload this to arduino board and let your car to move, in this code I keep safe distance of 30 cm you can modify as per your need.
so thats it I hope I provide much details , if some thing skip pls ask let do some thing creative and share what you make ....
thanks.