-
-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #944 from rittikadeb/vehicle-accident-prevention
Vehicle accident prevention
- Loading branch information
Showing
6 changed files
with
175 additions
and
1 deletion.
There are no files selected for viewing
Binary file added
BIN
+165 KB
...ehicle Accident Prevention System/Images/vehicle_accident_prevention_system.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+19.1 MB
...rmediate/Vehicle Accident Prevention System/Images/vehicle_accident_prevention_system.mp4
Binary file not shown.
65 changes: 65 additions & 0 deletions
65
IOT(Internet of Things)/Intermediate/Vehicle Accident Prevention System/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
|
||
|
||
|
||
|
13 changes: 13 additions & 0 deletions
13
IOT(Internet of Things)/Intermediate/Vehicle Accident Prevention System/requirements.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
96 changes: 96 additions & 0 deletions
96
...s)/Intermediate/Vehicle Accident Prevention System/vehicle_accident_prevention_system.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters