Professional Documents
Culture Documents
Arduino Reverse Car Parking Sensor PDF
Arduino Reverse Car Parking Sensor PDF
Arduino Reverse Car Parking Sensor PDF
PARKING SENSOR
The Reverse Parking Sensors that are equipped in the car are basically
Ultrasonic Proximity Sensors i.e. they use Ultrasonic Sensors to measure the
distance between the car and the object and warn the driver if the car is too
close.
Circuit Diagram
The circuit diagram of Arduino Car Reverse Parking Sensor circuit is given in
the image below.
Components Required
● Arduino UNO [Buy Here]
● HC-SR04 Ultrasonic Sensor
● BC548 NPN Transistor (any NPN Transistor can be used)
● 5V Buzzer
● 1N4007 PN Junction Diode
● 1KΩ Resistor (1/4 Watt)
● Mini Breadboard
● Connecting Wires
● 5V Power Supply
The principle of the circuit is as follows: The Ultrasonic Sensor sends acoustic
pulses and the Arduino measures the interval of each reflected signal. Based
on this time interval, Arduino then calculates the distance of the object.
Arduino then activates the Buzzer if the distance between the sensor and
object is less that a certain range.
The VCC and GND are connected to +5V and GND of the power supply while
the TRIG and ECHO are connected to Digital I/O pins 11 and 10 of Arduino
respectively.
Even though the buzzer used here is a 5V buzzer, I decided to use a driver
circuit for the buzzer consisting of an NPN Transistor. I have used BC548
along with a 1KΩ Resistor (for the base) to drive the buzzer.
Code
The Arduino code for the project is given below.
long duration;
float distance;
void setup()
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
pinMode(buzzPin, OUTPUT);
void loop()
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
distance = 0.034*(duration/2);
digitalWrite(buzzPin,HIGH);
else
digitalWrite(buzzPin,LOW);
delay(300);
Code Explanation
The code is very simple and if have followed our PORTABLE ULTRASONIC
RANGE METER project, then you can easily understand this code as well.
As per the data sheet of the HC-SR04 Ultrasonic Sensor, its working is as
follows:
Using the same principle in the code, first the TRIG is made HIGH for 10µS
using the following lines of code.
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
Then, the time is calculated for which the ECHO Pin is HIGH using the pulseIn
function of Arduino.
duration = pulseIn(echoPin, HIGH);
Finally, the distance in centimeters is calculated using the following line in the
code
distance = 0.034*(duration/2);
Working
When distance calculated is less then 100cm buzzer will start buzzing.