vijendra kumar
Published © CC BY-NC

Arduino-based Collision Detection Warning System

This kind of system is the fastest growing safety feature in automotive industries.

AdvancedFull instructions provided57,543
Arduino-based Collision Detection Warning System

Things used in this project

Story

Read more

Custom parts and enclosures

Arduino based collision detection warning system

Please use this pin information. You can change pin number as per yours but in that case you have to change code also.

Schematics

Arduino based collision detection warning system

Please follow this schematic to connect hardware to board and pin numbers.

Code

Arduino based collision detection warning system

Arduino
You can use this code for this system
////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    
}
}

Credits

vijendra kumar

vijendra kumar

2 projects • 39 followers

Comments