Introduction: Self- Driving Car

Picture of Self- Driving Car

1. This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com)

Step 1: Step 1: Get Your Parts

You will need:

1 simple remote control car from like walmart

2 arduino UNO boards

2 9 V batteries

2 9 V battery connectors for arduino

1 small breadboard

6 IR sensors

3 transistors

about 30 connector cables, various sizes

arduino IDE

1 soldering iron and solder

1 box

1 velcro pad

Step 2: Step 2: Soldering Connectors to the Remote Control Circuit Board

Picture of Step 2: Soldering Connectors to the Remote Control Circuit Board

Solder a transistor with its B and C legs on either side of the front, left, and back pushbutton, on the underside of the circuit board. Then solder a jumper wire to each transistors E leg, and a cable to each transistors B leg as well. The jumper cable from the Es should plug into the + rack of your breadboard, and the cables from your B legs for the forwards and backwards into pins on your first arduino and the cable from the left into your second arduino. Because of the way the circuit board is set up you can only do 3 directions. And need to add a second microprocessor to do the third.

Step 3: Step 3: Solder and Connect Your IR Sensors

Picture of Step 3: Solder and Connect Your IR Sensors

Solder one jumper cable to each leg of the IR sensor, plug in the leg labeled VCC to the + on your breadboard, the GND to the - on your breadboard, and the out into a different pin on your first arduino. Place the 6 with on at each of the 4 corners of the box,a dn the other 2 at the front and back, and cut out holes and let the 2 bulbs sit unubtrsucted outside the box. Also tape down the sensors.

Step 4: Step 4: Provide Power!!

Picture of Step 4: Provide Power!!

Give everything power! Connect each 9V battery to its connector and plug them into the round port on the side of each arduino.

Take a jumper wire from your first arduino's +5V pin and connect it to the top of your breadboards + rail.

Similarly, take a jumper wire from your first arduino's ground pin and connect it to the top of your breadboards - rail.

Also, connect a jumper cable from one digital pin of your first arduino to your second arduino, so we can send a signal of when to turn left from the first to the second (since all the IR sensors are connected to the first arduino, the second cant read them).

Step 5: Step 5: Write Your Code

Picture of Step 5: Write Your Code

Download and install the Arduino IDE, then write this code, and upload the first one to the first Arduino, and the second one to the second Arduino.

First arduino

/*
Created by Patrick Tipaldo

Student at USF for makecourse fall 2017

Released into the public domain

*/

int ir0 = 2; //each IR sensor

int ir1 = 3;

int ir2 = 4;

int ir3 = 5;

int ir4 = 6;

int ir5 = 7;

int ir0m = HIGH; // HIGH MEANS NO OBSTACLE

int ir1m = HIGH; //Ir measurement variable

int ir2m = HIGH;

int ir3m = HIGH;

int ir4m = HIGH;

int ir5m = HIGH;

int forwards =8; //high for forwards // these are connected to the cars controller

int backwards = 9; // high for backwards // we can send a voltage to circumvent the pusbutton and make it go. int left = 12; // low for left //connected to second arduino

void setup()

{

pinMode(forwards, OUTPUT);

pinMode(backwards, OUTPUT);

pinMode(ir0, INPUT);

pinMode(ir1, INPUT);

pinMode(ir2, INPUT);

pinMode(ir3, INPUT);

pinMode(ir4, INPUT);

pinMode(ir5, INPUT);

pinMode(left, OUTPUT);

}

void loop()

{

digitalWrite(left, HIGH); // initial conditions, when there is no obstacle just go straight

digitalWrite(backwards, LOW);

digitalWrite(forwards, HIGH);

delay(400);

digitalWrite(forwards, LOW);

delay(500);

ir0m = digitalRead(ir0);

ir1m = digitalRead(ir1);

ir2m = digitalRead(ir2); // read the IR sensors

ir3m = digitalRead(ir3);

ir4m = digitalRead(ir4);

ir5m = digitalRead(ir5);

if (ir0m == LOW)

{

digitalWrite(backwards, HIGH); // if top right detects obstacle, go back and left, unless an obstacle is //detected from behind, then go forwards

digitalWrite(left, LOW);

int i =0;

while ( i<2000)

{

if ((ir3m == LOW)|| (ir4m == LOW) || (ir5m == LOW)) //delay loop, just so we can continually check behind the //car

{ //3 is back left IR sensor, 4 is back, 5 is back right

digitalWrite (backwards, LOW);

digitalWrite(left, HIGH);

digitalWrite(forwards, HIGH);

}

i++;

}

digitalWrite(backwards, LOW);

digitalWrite(left, HIGH);

}

if (ir1m == LOW) //front IR sensor

{

digitalWrite(backwards, HIGH);

digitalWrite(left, LOW);

int i =0;

while ( i<3000)

{

if ((ir3m == LOW)|| (ir4m == LOW) || (ir5m == LOW))

{

digitalWrite (backwards, LOW);

digitalWrite(left, HIGH);

digitalWrite(forwards, HIGH);

}

i++;

}

digitalWrite(backwards, LOW);

digitalWrite(left, HIGH);

}

if (ir2m == LOW) // top left IR sensor

{

digitalWrite(backwards, HIGH);

digitalWrite(left, LOW);

int i =0;

while ( i<3000)

{

if ((ir3m == LOW)|| (ir4m == LOW) || (ir5m == LOW))

{

digitalWrite (backwards, LOW);

digitalWrite(left, HIGH);

digitalWrite(forwards, HIGH);

}

i++;

}

digitalWrite(backwards, LOW);

digitalWrite(left, HIGH);

}

}

Second arduino

/*
Created by Patrick Tipaldo

Student at USF for makecourse fall 2017

Released into the public domain */

int left = 7;

int right = 8;

int Ar1_left =4; // connected to first arduino which says when to go left

void setup()

{

pinMode(left, OUTPUT);

pinMode(right, OUTPUT);

pinMode(Ar1_left, INPUT); }

void loop()

{

if (Ar1_left == HIGH) //if first arduino says to go left, then go left

{

digitalWrite(left, HIGH);

delay(1500);

digitalWrite(left, LOW);

delay(500);

} //or else just dont

}

Step 6: Step 6: Let Your Car Drive! Refer to Circuit Diagram for Help

Picture of Step 6: Let Your Car Drive!  Refer to Circuit Diagram for Help

Use the velcro pad to pad your box to your car, turn it on and watch it drive!

Also you can refer to the circuit diagram if you need help.

The car operates using the sticks to push down the pushbuttons. The pushbutton, when pushed , lets current flow across it, so we are bypassing this and providing a signal on either side of the pushbutton to make the circuit think that the button is pushed and that current is flowing.

To do this we connect a transistor to either side, and when we provide a high signal, current flows across the transistor, or either leg of the pushbutton. Everything else is just basic wiring and soldering.

You could also 3D print the box on top, however i decided not too, as i believed the additional weight would weigh down the car and make it unable to move. So instead, I simply used a very light cardboard box, which i spray painted black to look more proffessional, and poked holes for the IR sensors.

Comments

Chrome98 (author)2017-12-07

Just because you're hacking doesn't mean you can't be neat and organized. Spaghetti wiring, no schematic, etc.

About This Instructable

426views

8favorites

License:

More by ptipaldo:Self- Driving Car
Add instructable to: