Introduction: Arduino Self-Driving Car
This is basically a Self-Driving Car powered by Arduino R-3 Development Board and a L293D Motor Shield.It uses the data given by the HC-SR04 Ultrasonic Sensor which is connected to analog pins of the arduino board. As an additional feature, I have added a Micro 90g servo which the ultrasonic sensor is fixed to. Basically what the servo does is, it makes the ultrasonic sensor to look around and search for different paths. So this was it, now lets get started with the project.
Step 1: The Materials Needed : (Really??)
Parts--
1- Arduino UNO R-3 Board Link: http://www.amazon.in/Arduino-ATmega328P-ATMEGA16U2...
2- L293D Motor Shield Link: http://www.amazon.in/L293D-Driver-Stepper-Shield-A...
3- BO Motors and Wheels (x4) Link: http://www.amazon.in/REES52-BOSET-Motor-Pieces-Scr...
4- HC-SR04 Ultrasonic Sensor Link: http://www.amazon.in/Arduino-Ultrasonic-Distance-M...
5- Ultrasonic Sensor Bracket Link: http://www.amazon.in/Cartoon-Ultrasonic-Mounting-B...
6- 90g Micro Servo Link: http://www.amazon.in/REES52-KG113-Tower-Servo-Moto...
7- 9 Volt Battery (x1) Link: http://www.amazon.in/Duracell-Alkaline-Battery-Dur...
8- 9 Volt Battery Clip Link: http://www.amazon.in/Banggood-50797-Battery-Connec...
9- Male to Female Jumper Wires (x4) Link: http://www.amazon.in/Banggood-53767-Female-Jumper-...
10- Plastic Box Link: (Come on, u can find that in ur home)
11- Wires Link: (You might find some in ur nearest hardware shop)
Tools--
1- Soldering Iron Link: http://www.amazon.in/amiciKart-Soldering-different...(A good iron for beginners)
2- Soldering Wire Link: http://www.amazon.in/Buyyart-BART_1-Rosin-Solder-S...(Flux inside the wire)
3- Hot Glue Gun Link: http://www.amazon.in/Stanley-69GR20B-Gluepro-Trigg...(I personally like it)
4- Hot Glue Sticks Link: http://www.amazon.in/All-Purpose-Melt-Glue-Sticks/...
5- Screwdriver Link: http://www.amazon.in/Precision-ScrewDriver-Repairi...
6- Screws Link: (Included with the servo)
7- Pliers Link: http://www.amazon.in/Stanley-70-482-Sturdy-Combina...(A good one)
Step 2: About the Motors (ooohh)
Solder the wires on each of the motor terminals and check them using the battery. Solder the negative or black wires on the left terminalsof the motor while the positive or red wires on the right terminals. Now glue the motors to the box.
Step 3: About the Motor Shield (: I )
Now plug the L293D Motor Shield on the Arduino UNO. Put the shield in this way that the reset button on the shield is facing towards the usb port and the power input of the arduino. Now connect the top-left motor to the M1 on the shield, down-left to the M2, top-right to the M3, down-right to the M4. Connect the positive and negative wires in the way as shown in the picture.
Step 4: Servo!! (: ) )
Connect the servo on the L293D Motor Shield as shown in the image. Now glue it to the box as shown.
Step 5: The Ultrasonic Sensor (???)
Now attach the ultrasonic sensor to the bracket and attach the wires corresponding to (VCC- Brown), (Trig-Yellow), (Echo- Green), (Gnd- Black). Now attach the the sensor to the motor shield as(VCC- 5v), (Gnd- Gnd), (Trig- Analog 0), (Echo- Analog 1).
Step 6: Batteries (Yes!!!, Some Juice!!!)
Note: First things first, you can use an external power supply if the battery is not working for you.
Now connect the positive battery clip wire to the M+ of the motor sheild and negative wire to the gnd.
Step 7: Libraries (Uhh, No Juice : ( )
Now first download the libraries.
1- Adafruit-Motor-Shield-library Link: https://github.com/adafruit/Adafruit-Motor-Shield-...
2- Arduino New Ping Link: https://bitbucket.org/teckel12/arduino-new-ping/do...
Now extract these libraries into: This PC> Documents> Arduino> libraries.
Don't forget to Rename these libraries to AFMotor and NewPing respectively.
If you dont have the Arduino IDE Link: https://www.arduino.cc/en/Main/Software
Step 8: Coding (Get Serious : I )
The Code is in the text file given.
Step 9: Batteries (Finally SOME JUICE!!!)
Now Plug-In The Battery.
Step 10: ENJOY!!!!!!!!!!!!!!!!!
ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!,ENJOY!!!!!!.
15 Comments
Question 2 months ago
can you share the working demonstration may be a youtube videl link of your video
2 years ago
Man do you have the video of the car driving ?
It would be helpful
Question 2 years ago
Hello, when I want to connect my ultrasonic sensor to the motor shield, there are no male or female header pins. Will the connection still work? Do I need to solder some header pins first?
Question 3 years ago on Step 3
Hello, I wasn't able to find l293b motor shield rather I found the l298n motor driver. So I was hoping if I could replace the motor shield with the motor driver??
3 years ago
Does this robot turn or rotate on its own in front of obstacles ?
can u send me videos related to it ! btw nice project...thank you.
mail ID : aadityajoshi300@gmail.com
4 years ago
I don't understand this:
if (curDist < COLL_DIST) {changePath();} // if forward is blocked change direction
moveForward(); // move forward
Shouldn't the moveForward call be in the if statement?. This of course would necessitate some changes to setup() to get thing started.
The reason I ask this is that right now moveForward is getting called every single time through the loop instead of just after a change in path, even though the car is already "moving forward". Which means power to the motor is pulsing when the the speedset loop runs. Or am I missing something?
Also why don't you do speed ramping when you turn? It looks like you just slam the motors forward on one side or the other when the turn finishes but go back to doing the speed ramping once you reenter the loop.
Overall though thank you for this. I really do appreciate it.
Question 4 years ago on Introduction
How does this work, are there any videos ?
Does it turn by itself ? Pls send em a vid
Email Kremerw@ramaz.org
4 years ago
When you use other motors, will it work?
4 years ago
Amaing kit,there are many benefits of using Arduino,especially for beginners
5 years ago
Cool robot.
Reply 4 years ago
Thaknks a lot brother.
4 years ago
BRO DOES THIS PROJECT ACTUALLY WORKS WITHOUT ANY BUGS , REPLY PLZ I AM WAITING
Reply 4 years ago
Yes this will work without any problem. My only recommendation is to use 8x AA batteries instead of a single 9 volt battery. Thanks for checking us out
5 years ago
I got an error when compiling; AF_DCMotor does not name a type and the highlignted line is:
AF_DCMotor rightMotor2(4, MOTOR34_1KHZ);// create motor #4, using M4 output, set to 1kHz PWM frequency.
I have downloaded the verson 2 of Adafruit library.
Can you help me please?
Reply 5 years ago
Hi rousseau210, there might be a problem while you have extracted the AF motor library as for me it was the same error when I was uploading the code. After you extract the AF motor library, there will be a main folder inside the extracted folder , copy the main folder and paste it in the libraries folder in Arduino and simply name it to AFMotor and the error must have gone. This worked for me. Hope it works for you : )