Introduction: How to Make Arduino Based Collision Detection Warning System

Step 1: Items and Material Required

Please gather the following items

  1. Computer :- This is required to write program and flash program to controller. Also you need to install arduino IDE which is available free at arduino website download section.
  2. Controller :- I used arduino micro-controller. This you can get at online seller like amazon etc.
  3. Sensor :- I used HR SC-04 ultrasonic sensor.
  4. Piezo Buzzer :- I used piezo buzzer to make audio warning.
  5. LED :- There is two type of LED i used to which is red LED and blue LED.
  6. Wires :- There were jumper wires required to make hardware connections. You need to take all type of jumper wires like both end male, both end female and one end male another end female type.

Step 2: Connect All Hardwares

The hardware you gather in first step, now connect all them to controller through wires.

Sensor to controller pin information :-

Sensor has four pins VCC, Trig, Echo and GND. Connect...

VCC pin to 5V on controller

GND pin to GND on controller

Trig pin to pin-7 on controller

Echo pin to pin-4 on controller

Piezo Buzzer to controller pin information :-

Piezo buzzer has two pin.

Connect one pin to pin-10 on controller

Connect another pin to GND on controller

Red LED to controller pin information :-

Red LED has two pin.
Connect one pin to pin-2 on controller

Connect another pin to GND on controller

Red LED to controller pin information :-
Red LED has two pin.

Connect one pin to pin-13 on controller

Connect another pin to GND on controller

Controller to Computer connection information :-
You have USB data cable that you got while buying arduino. By this data cable you connect computer to arduino board.Now launch the arduino IDE. After connecting to computer you must have to select board and port from menu.

please see the attached screen shot for the help.

Step 3: Write Arduino Program

In the previous step we defined pin information for the hardware. No that info we'll use to write program instructions.

Launch Arduino IDE and try to write program by yourself. Otherwise you can directly use my program or download the .ino format file attached.

While copying this code you have to be careful because some character used in program cannot be paste while writing this on instructable. Better to download .ino format file.

////Collision Warning System////

//// Year 2017 ////

//// Vijendra Kumar////

const int trigPin = 7;

const int echoPin = 4;

int buzz = 10;

long duration;

int distance;

// the setup function runs once when you press reset or power the board

void setup() {

// initialize digital pin 13 as an output.

pinMode(trigPin, OUTPUT);

pinMode(echoPin, INPUT);

pinMode(13, OUTPUT);

pinMode(2, OUTPUT);

Serial.begin(9600);

}

// the loop function runs over and over again forever

void loop()

{

// Clears the trigPin

digitalWrite(trigPin, LOW);

delayMicroseconds(2);

// Sets the trigPin on HIGH state for 10 micro seconds

digitalWrite(trigPin, HIGH);

delayMicroseconds(10);

digitalWrite(trigPin, LOW);

// Reads the echoPin, returns the sound wave travel time in microseconds

duration = pulseIn(echoPin, HIGH);

// Calculating the distance

distance= duration*0.034/2;

// Prints the distance on the Serial Monitor

if(distance <= 50 && distance >= 20)

{

digitalWrite(13, HIGH);

// digitalWrite(13, LOW);

// turn the LED on (HIGH is the voltage level)

}

else

{

digitalWrite(13, LOW); // turn the LED off by making the voltage LOW

// wait for a second

}

if(distance <= 20)

{

digitalWrite(2, HIGH);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

tone(buzz, 2000);

delay(100);

noTone(buzz);

tone(buzz, 2000);

delay(100);

noTone(buzz);

delay(100);

}

else

{

digitalWrite(2, LOW); // turn the LED off by making the voltage LOW

// wait for a second

}

}

Step 4: Flash Arduino Board

After making all connection we are ready to upload the program to arduino board. Please see the attached image for reference.

Step 5: How This System Works

Let me explain you that how this system works.

I defined three different zones.

Zone 1 :- No warning

Zone 2 :- Only visual warning (In this zone driver has to pay attention)

Zone 3 :- Both visual and audio warning ( Driver has to take necessary action to avoid collision)

Step 6: Test You Setup

Now whole system is ready to test. Please see the Both video to see the how to check the system is working.

Comments

author
AnnG52 (author)2017-06-04

Hello, I downloaded the code from here then uploaded in my arduino, I have double checked all the connections but the output was, my led is just turned on and my buzzer is just beeping.

author
sakethroyal (author)2017-03-17

how to download code

author
VijendraK (author)sakethroyal2017-04-19

You can download the attached file

author
DineshN26 (author)2017-03-11

I am also looking for the android mobole app interface woth arduino. Can somebody provide guidance for this ?

author
VijendraK (author)2017-03-11

Very nice work...
Apreciated...
Tried your code this is working good.

I am working on android interface with arduino. Can you please help me on this?

author
007kramerica007 (author)2017-03-04

What are your thoughts about using a sensor with a greater range of detection?

HC-SR04 is an ultrasonic ranging module that provides 2 cm to 400 cm non-contact measurement function.

400cm or 4 meters or 13feet.

The average car or sedan is 190 inches / 15 feet.

I think you would need to use a sensor that can see farther than 13 feet.. it's probably not enough distance to give you a reaction time.

A LIDAR sensor would give you a range of 40 meters! This would give you a better chance at reacting to a traffic event.

https://www.sparkfun.com/products/14032 149.99 - quite a bit more expensive.

author

Thanks pal. I would like to say thank you first. You are thinking in real time on right track. This HC SR04 has limitations. My system will give idea of a collision system and how it works. If anyone is interested to work further with good sensor always welcome.

author
GürhanÇ (author)VijendraK2017-03-09

Hi i was planning to make the same project and start to check options, but as 007 mentioned, we need at least 40-50m range sensor. also GPS needed. as the distance to next car depends on the speed. like if you are going by 50km/h, you need to keep minumum 25m's distance, but if you go 100km/h than you need to have 50m distance. which is calculated by the distance car takes in 2 seconds with its current speed.

author
Maker Saga (author)2017-02-20

I was just looking to make something like this for an automatic braking system for my go kart. How does this not trip up false alarms when making tight turns?

author
VijendraK (author)Maker Saga2017-03-02

You may need to debug you warning system and codes for that.

author
motions (author)2017-03-02

Or just watch where you're driving.

author
kentokenta (author)2017-03-01

what value resistors for 2 LED's

author
VijendraK (author)kentokenta2017-03-02

This works accordingly
I = V / R

V = rated voltage - voltage drop

I = Current in "mA"

V = Voltage "V"

R = Resistance "ohm"

author
VijendraK (author)kentokenta2017-03-02

Pal, you got a right question.
As per my opinion you can use any values from 220 Ω to 1.5KΩ are probably OK.
So as per your brightness requirement you can select resister value.

you may perform an experiment, take 3 different resister value and try for brightness level.

Thanks,
Vijendra

P.S. Subscribe my YouTube channel for upcoming updates.

About This Instructable

5,082views

54favorites

License:

Bio: Hi... This is Vijendra. I am a mechanical engineer by profession. I love to find new and innovative.
More by VijendraK:Angle of Projections : Engineering DrawingHow to make Arduino based collision detection warning systemHow to Make Automatic Door Opening Using Ultrasonic Sensor HRSC04
Add instructable to: