How to Make Arduino Based Collision Detection Warning System





Introduction: How to Make Arduino Based Collision Detection Warning System

About: Hi... This is Vijendra. I am a mechanical engineer by profession. I love to find new and innovative.

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);



// the loop function runs over and over again forever

void loop()


// Clears the trigPin

digitalWrite(trigPin, LOW);


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

digitalWrite(trigPin, HIGH);


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)




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);




tone(buzz, 2000);




tone(buzz, 2000);



tone(buzz, 2000);







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.



    • Oil Contest

      Oil Contest
    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    19 Discussions

    How to consider the zone 1 ,2,3 and make it run effectively

    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.


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

    This works accordingly
    I = V / R

    V = rated voltage - voltage drop

    I = Current in "mA"

    V = Voltage "V"

    R = Resistance "ohm"

    Good work but can you tell me how to activate abs (automatic braking system) in this project, I want to make a car that both detect collision and activates brake. Can anyone tell me about this by 3 days because I have a project to do.


    1 year ago

    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.

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

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

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

    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. 149.99 - quite a bit more expensive.

    2 replies

    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.

    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.

    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?

    1 reply

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

    Or just watch where you're driving.