Introduction: Obstacle Preventing Car.

I modified a toy car into obstacle preventing car mean when some thing come in front of car it will turn. I keep it as simple as possible to be recreated. I use less expensive components.

All you need:

  • A simple toy car
  • Ultrasonic sound distance sensor
  • Arduino neon
  • A 9v battery
  • Some jumper wires
  • Two motor

I use two motor when need of turn arise one of that motor will be slow down causing the car to turn.

Step 1: Wiring.

Wiring is most simple part of this project just fallow the given systematic .

Step 2: Program the Arduino

The programing is simple it is given below.

Just fit all the component in the car and the ultrasonic sonic sensor must be out of the car in front.

const int trigPin = 12;
const int echoPin = 11;

long duration;
int distance;
void setup() {
pinMode(trigPin, OUTPUT); 
pinMode(echoPin, INPUT); 
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(8, OUTPUT);
digitalWrite(10, HIGH);
digitalWrite(8,LOW);
digitalWrite(9, HIGH);
}
void loop() {
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
distance= duration*0.034/2;
delay(50);
if(distance<40 and distance>10);
{ digitalWrite(10, LOW);
delay(1000);
digitalWrite(10, HIGH);
}
 if (distance<10);
{ digitalWrite(10, LOW);
 digitalWrite(9,LOW);
 digitalWrite(8,HIGH);
 delay(1000);
 digitalWrite(10,HIGH);
 digitalWrite(8,LOW);
 digitalWrite(9, LOW);
delay(1000);
digitalWrite(9, HIGH);
}

Step 3: Finishing

Just put all of your component in the car and you are ready to go just power on and your ordinary car will prevent all obstacles and turn when wall or any thing come in front of car.

Comments

author
DIY Hacks and How Tos made it! (author)2017-04-30

Cool robot design. I like how the range sensor kind of makes it looks like Wall-E

author
ZakriyaP made it! (author)ZakriyaP2017-05-01

:)

author
WarenGonzaga made it! (author)2017-04-30

cool project keep it up!

author
ZakriyaP made it! (author)ZakriyaP2017-05-01

thanks Sir !

author
Gelfling6 made it! (author)2017-05-01

Only one minor critique, Noticed in the wiring diagram, Digital pin 8 is not connected to anything, so misc. code.. (a few bytes saved, but..) Nicely done though!!!

author
ZakriyaP made it! (author)ZakriyaP2017-05-01

sorry, actually common gnd of motors goes to pin 8.

this will reverse the car if distance become less the 10.

About This Instructable

424views

10favorites

Bio: I live in Pakistan . I am 16 year old and I am passionate about electronics since my childhood. I have a hobby to design and ... More »
More by ZakriyaP:Vanlife Cheap Lab for Electronic Hobiest.Matal Levitating Device.Generate Electricity From Vinegar.
Add instructable to: