How to Make an Obstacle Avoiding Car
by vineethrao50 in Circuits > Sensors
536 Views, 1 Favorites, 0 Comments
How to Make an Obstacle Avoiding Car
In this tutorial ill be showing you how to build a obstacle avoiding or a smart car(both are the same, just the name is......).What it does is it will stop when an object comes in front of it ...
Things required-
- A car base plate with wheels
- Power supply
- Arduino
- Wires
- Relay
- Ir sensor
Making the Base Plate
You can make whichever way you want but I made this a way I found easy.
What I did is took a simple wooden plate type thing and then cut it according the size of the of the tyres(the space I left for the tyres).
Mounting
For mounting,If you use the base plate I've done here then you can easily mount the components on it.It does not actually matter where you mount the components but the sensor should be facing ahead without any obstacle coming before it...Better let it be just at the front so that it can detect objects more accurately....
The Circuit
So now for the circuit part, its not that difficult,though you may have to give a separate power supply for the Arduino which I have not shown in this diagram.So what happens in the circuit is that when the sensor sends message to the Arduino that there is some obstacle in front of it ,which will then cut the circuit and stop the car its that simple you can also add some leds to make it look more good....
Code
And now the code....
int irrecv=A0; int motor=6; void setup(){ pinMode(irrecv,INPUT); pinMode(motor,OUTPUT); } void loop(){ int i=digitalRead(irrecv); if(i==HIGH){ digitalWrite(motor,HIGH); /*low will make the motor spin as the gnd pin is connected to it.*} else{digitalWrite(motor,LOW)} }
If you are using leds to decorate then use this code instead of it-
int irrecv=A0; int motor=6; int led=13;//led computable pin void setup(){ pinMode(irrecv,INPUT); pinMode(motor,OUTPUT); } void loop(){ int i=digitalRead(irrecv); if(i==HIGH){ digitalWrite(motorpin,HIGH); /*low will make the motor spin as the gnd pin is connected to it.*/} else{digitalWrite(motor,LOW); digitalWrite(led,HIGH) } }
Done!
Making It Better
Its the same design just with a different sensor, because it it gives me a better range and it also cannot be deflected by the sun because it does not depend on IR rays while the IR sensor as the name suggests depends on IR rays which can be deflected by the sun.