Arduino Reverse Car Parking Sensor PDF

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

ARDUINO REVERSE CAR

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

Principle of the Circuit


As mentioned earlier, the Ultrasonic Sensor is the main unit (component) that
is responsible for measuring the distance. Arduino UNO acts as the main
controlling unit that will control the Ultrasonic Sensor, calculate the distance
and activate the buzzer.

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.

Design of Arduino Car Reverse Parking Sensor Circuit


The design of the Arduino Car Reverse Parking Sensor Circuit is very simple.
Starting with the Ultrasonic Sensor, it has 4 pins: VCC, TRIG, ECHO and
GND.

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.

const​ ​int​ trigPin = ​11​;

const​ ​int​ echoPin = ​10​;

const​ ​int​ buzzPin = ​6​;

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);

duration = ​pulseIn​(echoPin, HIGH);

distance = ​0.034​*(duration/​2​);

​if​ (distance < ​100​)

​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:

The TRIG Pin should be high for a minimum of 10µS.

After this, the Ultrasonic Sensor automatically sends 8 acoustic pulses of


40KHz frequency.
The time between this and the reflected signal is calculated by reading the
HIGH on the ECHO pin.

Distance can be calculated as Time (for which ECHO is HIGH) * Velocity of


Sound (340m/s) / 2.

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.

You might also like