Safe distance maintaining Car to Avoid accident using Ultrasonic Sensor

(Last Updated On: June 12, 2019)

safe distance

Description:

In this Tutorial, you will learn how to make an automatic safe distance maintaining control system for a Car to avoid accidents using Ultrasonic sensor and Arduino Uno. With the help of such control system the car speed is automatically adjusted depending on the distance… This control system is entirely based on the Arduino, Ultrasonic Sensor and L298N motor driver.  In this Tutorial I will also explain what the safe distance is, and how the safe distance maintaining technology can be used in real cars. I will share with you two methods that can be used in real cars, which will help you stay safe.



This is the 4th  version of the Robot Car. While in the 3rd version

 

I used the flex sensor and the joystick together to control the same robot car, in this project the flex sensor was used as the accelerator and the joystick was used to control the car’s forward, left, right and reverse movement, I named this project as wireless hand gesture + joystick robot car…

While in the 2nd version

 

https://www.electroniclinic.com/wireless-joystick-controlled-robot-car-using-arduino-433mhz-rf-and-l298n-motor-driver/

 I used only the joystick to control the speed and movement of the robot Car. The program used in this project was a little bit complex, so that’s why I decided to make another version of this robot and use a separate sensor for the speed controlling. So that’s why I created version 3.



While in the first version

I used an Android cell phone to control the Robot Car using the hc-05 Bluetooth module.

This Tutorial is based on my previous tutorials,L298N Motor driver Getting Started tutorial:

in this tutorial I explained, how to assemble the robot parts and how to use the L298N motor driver to control the forward, left , right and reverse movement.In this tutorial I also explained how to control the speed of a dc motor using the pulse width modulation. …

If you are a beginner and you have never used the L298N motor driver then I highly recommend you should first watch this tutorial and then you can resume from here.



The components and tools used in this project can be purchased from Amazon, the components Purchase links are given below:

Arduino Uno: https://amzn.to/2tVz1vu
Mega 2560: https://amzn.to/2ze1kdu
Robot Car chassis kit: https://amzn.to/2tTpkgo
L298N dual H-Bridge motor driver: https://amzn.to/2XF4sam
HC-SR04 Ultrasonic Sensor: https://amzn.to/2GJrjgP
Joystick: https://amzn.to/2E2Q0kI
433Mhz tx and rx: best offer https://amzn.to/2EkVMyN
Flex sensor with best price: https://amzn.to/2qeCvqJ
330 ohm resistors pack: https://amzn.to/2NtlAeh
5v 2A adaptor: https://amzn.to/2GsNfcw
2n2222 npn transistors: https://amzn.to/2EmXsIb
10k Resistor: https://amzn.to/2KTd6OW
lm7805 Voltage Regulator: https://amzn.to/2IZEl5x
330-ohm resistors pack: https://amzn.to/2NtlAeh
female DC power jack socket: https://amzn.to/2KEo1gt
470 uf capacitors: https://amzn.to/2xDCOzf
5×7 cm vero board: https://amzn.to/2OHGbvn
female headers: https://amzn.to/2zqmtiJ
connection wires: https://amzn.to/2DpBuW7
Super Starter kit for Beginners: https://amzn.to/2KJvmKG
Jumper Wires: https://amzn.to/2KMoVXs
Bread Board: https://amzn.to/2MS4q8X
12v Adaptor: https://amzn.to/2Ntr6h1
PCB plate: https://amzn.to/2IUwpCt
Variable Supply: https://amzn.to/2MT4Qfj
Digital Multimeter: https://amzn.to/2Nvft9i
Vero Board / strip board: https://amzn.to/2MTf9jD
Soldering iron kit: “best” You guys should definitely purchase this: https://amzn.to/2zfoNuJ
Solder wire: https://amzn.to/2ufUMWf
Wire Stripper: https://amzn.to/2KOqxfU
wire cutter: https://amzn.to/2ucIq14
PCB small portable drill machine: https://amzn.to/2Nu62XF

Safe Distance:

safe distance

You may already know the danger of following a car too closely as a violation of the law and how frequently it causes accidents..In this tutorial, we will focus on how to avoid this problem. You will learn how to judge a safe following distance,




safe distance

so that you can always maintain enough space in front of you whenever you drive, to picture this space in your minds eyes, think of it as a space cushion as it is often called.

safe distance

Following distance is defined as the distance between you and the vehicle in front of you when you are both moving on the road way.

safe distance

When driving you must always be prepared for the car in front of you to stop, slow down or react to unexpected road conditions ahead. It could be that the vehicle in front of you is slowing for stop traffic in front of them or reacting to traffic signals, children, animals etc.



In the past say when your parents were learning to drive, the way that the idea of a space cushion was generally taught in driver education classes was in terms of car lengths. So for example you would have learned that there should be roughly one full car length between you and the car in front of you for every 10 miles per hour of speed that you are travelling.

safe distance

So if you are travelling at 50 miles per hour you should be five car lengths behind the car in front of you..Driving Professionals finally realized that for most of us figuring out how many car lengths you are behind another car is really difficult…

To solve this problem you will need to make an automatic system that can measure the distance between you and the car in front you. For the distance measurement we can use the Ultrasonic sensor.  The ultrasonic sensor with Arduino can be used in different ways. For example

    1. You can make an automatic deceleration system. As the distance between you and the car in front of you decreases, your car speed will automatically reduce to maintain the safe distance. Now implementing this technology on real cars can be really difficult without the help of skilled programmers and mechanical experts, as this will require some changes in the car mechanical system. So don’t try this on a real car, but you can use this on a robot car to understand this concept.

safe distance

ii. you can use some led’s. Let’s say for every 1 meter of distance you can light up one led. As a normal ultrasonic sensor is capable of measuring the distance up to 5 meters, it means you can use 5 led’s. so this way you know exactly how far you are from the car in front of you and then manually you can increase or decrease the speed. Now you can try this by yourself as its safe.




safe distance

3. Or you can use a buzzer that is activated when the distance between you and the car in front of you is less than 5 meters. This method works best in situations when you are not looking at the leds. So method number 2 and 3 can be combined together and can be implemented in real cars without any problem.

safe distance

Using led’s and buzzer is very simple, which you can do by yourself and these two methods can be used in real cars without any problems and it won’t need any changes in the car control system. In this episode I will show you how to make an automatic deceleration system for a robot car, just to present to you how cool it would be if this technology is implemented in every car.



Interfacing:

For the connections explanation watch video Tutorial Click Here

Circuit Diagram:

safe distance

Programming:

For the step by step programs explanation watch video given at the end of this Article. If you have any questions let me know in a comment.



Program 2: Led’s Controlling

Watch Video Tutorial:

Recommended For You

About the Author: Engr Fahad

My name is Shahzada Fahad and I am an Electrical Engineer. I have been doing Job in UAE as a site engineer in an Electrical Construction Company. Currently, I am running my own YouTube channel "Electronic Clinic", and managing this Website. My Hobbies are * Watching Movies * Music * Martial Arts * Photography * Travelling * Make Sketches and so on...

Leave a Reply