Obstacle Avoiding Arduino Car

4,827

55

16

Introduction: Obstacle Avoiding Arduino Car

About: Electrical engineer by profession

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 ......

Step 1: 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

Step 2: 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.

Step 3: 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.














Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    16 Discussions

    0
    hridey
    hridey

    2 years ago

    wow I

    have also made it but my web cam has been not working for a while

    0
    AIP06
    AIP06

    3 years ago

    can you make a fritzing or some type of wiring that i can understand please

    thanks!

    0
    EzzeldinH
    EzzeldinH

    4 years ago

    how to wire the ultrasonic sensor

    0
    Mr innovative
    Mr innovative

    Reply 4 years ago

    sensor vcc to arduino 5v
    sensor gnd to arduino and
    sensor ECHOPIN to arduino 7
    sensor TRIGPIN to arduino 8

    0
    MNM_25-07
    MNM_25-07

    Reply 4 years ago

    By Arduino 7 and Arduino 8, you mean the A7 and A8 pin right, Thank you

    0
    bigerboy654
    bigerboy654

    4 years ago

    Upload a video plzz

    0
    Mr innovative
    Mr innovative

    Reply 4 years ago

    actually I disassembled it some days ago & haven't record any video, but I will surely help you in this feel free to ask anything happy to help you

    0
    Mr innovative
    Mr innovative

    Reply 4 years ago

    you can mail me on sharmaz747@gmail.com

    0
    bigerboy654
    bigerboy654

    4 years ago

    And what are the sizes of the bread board

    0
    Mr innovative
    Mr innovative

    Reply 4 years ago

    Color: White

    - Solderless breadboard with 400 tie points
    - Self-adhesive tape is included on the back
    Dimensions: 3.27 in x 2.09 in x 0.35 in (8.3 cm x 5.3 cm x 0.9 cm)
    Weight: 1.38 oz (39 g)

    0
    bigerboy654
    bigerboy654

    4 years ago

    Where can I buy or did you buy the materials?

    0
    EzzeldinH
    EzzeldinH

    4 years ago

    there is error compiling the code this is the message : Arduino: 1.7.10 (Windows 8.1), Board: "Arduino Uno"

    sketch_jun04a.ino: In function 'void loop()':

    sketch_jun04a.ino:32:23: error: expected ')' before ';' token

    sketch_jun04a.ino:32:24: error: expected primary-expression before ')' token

    sketch_jun04a.ino:32:24: error: expected ';' before ')' token

    sketch_jun04a.ino: At global scope:

    sketch_jun04a.ino:55:1: error: expected declaration before '}' token

    Error compiling.

    This report would have more information with

    "Show verbose output during compilation"

    enabled in File > Preferences.

    0
    Mr innovative
    Mr innovative

    Reply 4 years ago

    hello ezzel
    copy past the code in arduino idea and reple the ``#define`` by ``int``
    your problem get solve.
    as you can see in very first two line of code. you find
    #define ECHOPIN;
    #define TRIGPIN;
    Chang it like this.
    int ECHOPIN;
    into TRIGPIN;

    and you know done compile seccessfully

    0
    Mr innovative
    Mr innovative

    Reply 4 years ago

    int ECHOPIN;
    int TRIGPIN;