Skip to content

Commit

Permalink
Merge pull request #944 from rittikadeb/vehicle-accident-prevention
Browse files Browse the repository at this point in the history
Vehicle accident prevention
  • Loading branch information
Kushal997-das authored Oct 24, 2023
2 parents 564c46e + 29c37c3 commit dc3bda2
Show file tree
Hide file tree
Showing 6 changed files with 175 additions and 1 deletion.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Vehicle Accident Prevention System


## Aim

To design a Arduino Based Vehicle Accident Prevention System.


## Purpose

This project proposes a quite efficient way to prevent road accidents.


## Components Required

* Arduino UNO
* Breadboard
* Connecting Wires
* LCD
* Potentiometer
* Ultrasonic Sensor
* Servo Motor
* Buzzer
* 1 Red LED
* 1 Green LED
* 2 Resisitors

## Short Description

The project deals with prevention of accident by sending alarm and a warning message to the driver if there are other vehicles in the vicinity. It also has a feature of automatic breaking system which turns on when any vehicle is too close than the given threshold distance.

## Workflow of the Project

- The servo motor acts like the breaking system of the vehicle.
- When vehicle is greater than 3m greater than the subject:
- Green LED is turned on.
- **Safe Distance** message is displayed on the LCD screen.
- When vehicle is lesser than 3m and greater than 1.5m close to the subject:
- Green LED is turned on.
- **Caution Message** is displayed on the LCD screen.
- When vehicle lesser than 1.5m and greater than 1m close to the subject:
- Red LED is turned on.
- **Apply Break** message is displayed on the LCD screen.
- When vehicle is less than 1m from the subject:
- Automatic Brakes are applied.
- Green LED is turned on.
- **Brakes Applied** messsage is displayed on the LCD screen.


## Setup instructions

- Design and assemble the circuit as shown in the image.
- Check the connections of all the components.
- Upload the code which is provided.
- Start the simulation

## Output

![image](https://user-images.githubusercontent.com/76259897/156437565-964db7e8-67b6-432a-8e26-f1da12d26c31.png)

[Simulation Video](./Images/vehicle_accident_prevention_system.mp4)




Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
| Component | Quantity |
| ------------------| ------------- |
| Arduino UNO | 1 |
| Breadboard | 1 |
| Connecting Wires | 22 |
| LCD | 1 |
| Potentiometer | 1 |
| Ultrasonic Sensor | 1 |
| Servo Motor | 1 |
| Buzzer | 1 |
| Red LED | 1 |
| Green LED | 1 |
| Resistors | 2 |
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include <LiquidCrystal.h> // Include library for LCD.
LiquidCrystal lcd(2, 3, 4, 5, 6, 7);
#include <Servo.h> // Include library for Servomotor.
int distanceThreshold = 0; // Initiaze threshold distance

Servo myservo;
int cm = 0;
int green = 8;
int red = 9;
int buzzer = 13;
int pos = 0;

long readUltrasonicDistance(int triggerPin, int echoPin)
{
pinMode(triggerPin, OUTPUT);
digitalWrite(triggerPin, LOW);
delayMicroseconds(2);
digitalWrite(triggerPin, HIGH);
delayMicroseconds(10);
digitalWrite(triggerPin, LOW);
pinMode(echoPin, INPUT);
return pulseIn(echoPin, HIGH);
}

void setup()
{
pinMode(green, OUTPUT);
pinMode(red, OUTPUT);
pinMode(buzzer, OUTPUT);
lcd.begin(16, 2);
myservo.attach(12);
Serial.begin(9600);
}

void loop()
{
lcd.clear();
cm = 0.01723 * readUltrasonicDistance(11,10); //Calculation of distance

if( cm >=300) // Condition 1
{
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(buzzer, LOW);
lcd.setCursor(1,0);
lcd.print("Safe Distance");
}
if (cm <=300 && cm > 150) // Condition 2
{
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(buzzer, LOW);
lcd.setCursor(2,0);
lcd.print("Be Cautious!");
lcd.setCursor(0,1);
lcd.print("Chance of Impact");

}

if (cm <= 150 && cm > 100) // Condition 3
{
digitalWrite(red, HIGH);
digitalWrite(green, LOW);
tone(buzzer,800,1000);
lcd.setCursor(4,0);
lcd.print("Danger!");
lcd.setCursor(0,1);
lcd.print("Apply Breaks!!!");

}

if (cm <= 100) // Condition 4
{
digitalWrite(red, LOW);
digitalWrite(green, HIGH);
digitalWrite(buzzer, LOW);
lcd.setCursor(0,0);
lcd.print("Breaks Applied!");
lcd.setCursor(0,1);
lcd.print("You are Safe Now");
for (pos = 1; pos <= 90; pos ++) // Changes servo position
{
myservo.write(pos);
delay(5);
}
for (pos = 90; pos >= 1; pos --)
{
myservo.write(pos);
delay(5);
}
delay(1000);

}

delay(1000);
}
2 changes: 1 addition & 1 deletion IOT(Internet of Things)/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

| S-No. | Projects | S-No. | Projects | S-No. | Projects |
|:--:|:--:|:--:|:--:|:--:|:--:|
| 01. | [Gas leakage detection](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Intermediate/gas%20leakage%20detection)
| 01. | [Gas leakage detection](https://github.com/Kushal997-das/Project-Guidance/tree/main/IOT(Internet%20of%20Things)/Intermediate/gas%20leakage%20detection) | 02. | [Vehicle Accident Prevention System](https://github.com/rittikadeb/Project-Guidance/tree/vehicle-accident-prevention/IOT(Internet%20of%20Things)/Intermediate/Vehicle%20Accident%20Prevention%20System)

## Level 3: Advanced 🚀

Expand Down

0 comments on commit dc3bda2

Please sign in to comment.