A Smart Device to Warn the Driver of the Car
The Smart Device Helps the Driver of the Car by Giving Accurate Data on the Distances between the Car and the Car in Front of him
Which Helps the Driver to keep a Safe Distance
Thus, it Helps Reduce Accidents
Website tinkercad
Arduino IDE Program
USB Cable Arduino
Arduino Uno
Ultasonic Sensor
Jumper Wires
Breadboard
Buzzer
LEDs ( Red, Green,Yellow)
SlideSwitch
cardboard box
I opened the tinkercad website
I choose from a list Component ( UltasonicSensor - Buzzer - Arduino uno -SlideSwitch - LEDs- Resistor 220 Ω - LCD )
Connect the ends of the components using wiring
connection:
trigger pin UltasonicSensor on pin 2.
echo pin UltasonicSensor on pin 3.
Red LED on pin 4.
Yellow LED on pin 5.
Green LED on pin 6.
Buzzer on pin 7.
slideSwitch on pin 8.
Scl pin LCD on pins A5.
SDA pin LCD on pins A4.
I Wrote the Code
I used Simulation to Make Sure the Circuit Worked
inputs is (UltasonicSensor - slideSwitch )
outputsis ( Buzzer - LEDs - LCD )
code:
I Added my Libraries at first.
I defined a variable
Then Defined all my Components and Divided them into Inputs and Outputs.
Slideswitch must be turned on for the device to work
If the distance in front of the car is greater than or equal to 50 cm
A message " Safe " will appear on the LCD and GreenLed lights up
else if the distance in front of the car is less than 50 cm and greater than 30 cm
A message " Be careful " will appear on the LCD and the yellow LED will light up
else if the distance in front of the car is less than 30 cm
A message "Dangerous " will appear on the LCD and the Red LED will light up
And the buzzer works
OFF
Safe
Destance > 50 cm
Be careful
Destance < 50 cm
&&
Destance < 30 cm
Dangerous
Destance < 30 cm
I connected the wires as in the circuit diagram shown earlier
I used an Empty Cardboard Box to Hold the Components Inside
to Simulate a Car
1- I had a problem installing liquidcrystal I2C library
I could not find the required library
With the help of Instructor the problem was solved using an alternative library
2- I encountered a problem while connecting the clck terminal and the data terminal of the LCD with the Arduino
With the help of the Instructor, the problem was solved
It turned out that the error was in the reflection of the sides between A4 and A5
Operation Video