Car Reverse Parking Using Ultrasonic

Introduction: Car Reverse Parking Using Ultrasonic

About: I am Professional Engineer and Part timely hobbyist in Arduino, NodeMCU, IoT Cloud,AI ,Robotic, College & School student projects.

In this project Arduino Based Parking System using Ultrasonic Sensor and Android application via Blue tooth HC-05. Totally 8 sensor to used for finding parking slot and detecting/sensing object in front and back side of the car. In this project demo Purpose we are used single Ultrasonic sensor used for explanation. and additionally interface with android application and Bluetooth connectivity.

Components Required
1 × Breadboard

1 × Arduino Uno R3

1 × ULTRASONIC Sensor (HC-SR04)

1 x Bluetooth module HC-05 1X 16x2 LCD display with I2c module

1 x Buzzer

1x LED for PWM (BREAKING CONTROL) Android mobile for Mobile display Circuit Diagram:

Explanation: The HC-SR04 ultrasonic sensor uses SONAR to determine the distance of an object just like the bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package from 2 cm to 400 cm or 1” to 13 feet.

Features

Here’s a list of some of the HC-SR04 ultrasonic sensor features and specs:

Power Supply :+5V DC

Quiescent Current : <2mA

Working Current: 15mA

Effectual Angle: <15°

Ranging Distance : 2cm – 400 cm/1″ – 13ft

Resolution : 0.3 cm

Measuring Angle: 30 degree

Trigger Input Pulse width: 10uS

Dimension: 45mm x 20mm x 15mm

How It Works –

Ultrasonic Sensor Pins VCC: +5VDC Trig : Trigger (INPUT) Echo: Echo (OUTPUT) GND: GND It emits an ultrasound at 40 000 Hz which travels through the air and if there is an object or obstacle on its path It will bounce back to the module. Considering the travel time and the speed of the sound you can calculate the distance.

The HC-SR04 Ultrasonic Module has 4 pins, Ground, VCC, Trig and Echo. The Ground and the VCC pins of the module needs to be connected to the Ground and the 5 volts pins on the Arduino Board respectively and the trig and echo pins to any Digital I/O pin on the Arduino Board. In order to generate the ultrasound you need to set the Trig on a High State for 10 µs. That will send out an 8 cycle sonic burst which will travel at the speed sound and it will be received in the Echo pin. The Echo pin will output the time in microseconds the sound wave traveled.

For example, if the object is 10 cm away from the sensor, and the speed of the sound is 340 m/s or 0.034 cm/µs the sound wave will need to travel about 294 u seconds. But what you will get from the Echo pin will be double that number because the sound wave needs to travel forward and bounce backward. So in order to get the distance in cm we need to multiply the received travel time value from the echo pin by 0.034 and divide it by 2. speed of sound: v=340m/s v=0.034cm/µs

Time=distance/speed t=s/v; therefore 10/0.034/2=294µs Distance: s=t*0.034./2

In this the ultrasonic sensor reads and writes the distance to an object in the serial monitor. In the setup you have to define the triggerPin as an output and the echoPin as an Input and also start the serial communication for showing the results on the serial monitor. The trigger pin is connected to digital pin 8, and the echo pins is connected to digital pin 9.

You also create three variables of type long: duration, cm. The duration variable saves the time between the emission and reception of the signal. The cm variable will save the distance in centimeters.

In the setup(), initialize the serial port at a baud rate of 9600, and set the trigger pin as an output and the echo pin as an input. //Serial Port begin

Serial.begin (9600);//Define inputs and outputs

pinMode(triggerPin, OUTPUT);

pinMode(echoPin, INPUT);

In the loop(), trigger the sensor by sending a HIGH pulse of 10 microseconds. But, before that, give a short LOW pulse to ensure you’ll get a clean HIGH pulse. First you have to make sure that the triggerPin is clear so you have to set that pin on a LOW State for just 2 µs. Now for generating the Ultra sound wave we have to set the triggerPin on HIGH State for 10 µs. Using the pulseIn() function you have to read the travel time and put that value into the variable “duration”. This function has 2 parameters, the first one is the name of the echo pin and for the second one you can write either HIGH or LOW.

digitalWrite(triggerPin, LOW);

delayMicroseconds(2);

digitalWrite(triggerPin, HIGH);

delayMicroseconds(10);

digitalWrite(triggerPin, LOW);

Then, you can read the signal from the sensor – a HIGH pulse whose duration is the time in microseconds from the sending of the signal to the reception of its echo to an object.

duration = pulseIn(echoPin, HIGH);

Finally, you just need to convert the duration to a distance. We can calculate the distance by using the following formula: example: distance = (traveltime/2) x speed of sound distance= duration*0.034/2; At the end we will print the value of the distance on the Serial Monitor.

For LED brightness control (PWM ), and connected in Pin 6. Future development: This pin used for the Breaking control system for electrical vehicle, If the Front mud guard sensor sense the range upto 4 to 5 meter and Produce PWM signal respectively depends on Front obstacle or front Car distance. This PWM signal is feed to Breaking control signal to avoid Accident or feed to Speed Control to Keep distance.

long x;

In Loop

x=(duration/2)/29.1;

x=map(x,0,100,255,0);

if(x<255 && x>10) //code stability condition

{ analogWrite(6,x);

} else if (x<10) {

analogWrite(6,0); }

else { analogWrite(6,0); }

Code for Buzzer alarm for object in near by, and Buzzer connected in Pin 7.

int Buzzer = 7;

In loop

if (distance <= 33 && distance >= 0) { // Buzzer start sound when Object near by below 33cm. digitalWrite(Buzzer, HIGH); }

else { // Don't buzz digitalWrite(Buzzer, LOW); // // Buzzer stop sound when Object away to 34cm. } // Waiting 60 ms won't hurt any one delay(60);

First, pin your LCD with I2C board on the breadboard and power the breadboard by connecting a wire from "5V" (Positive) on your Arduino to the positive row on the breadboard and another one from "GND" (ground or 0V) to the negative row.

Then connect the LCD to the I2C module and I2C to Arduino:

I2C SCL pin 4 - Arduino pin A5

I2C SDA pin 3 - Arduino pin A4

I2C GND pin 2 – 0V

I2C VCC pin 1 – 5V

Then connect the Tx(Transmit) pin on your Bluetooth module to the Rx (Receive) on the Arduino, and connect the Rx pin on your BT module to the Tx on the Arduino. Finally, power the BT module by connecting the VCC (or 5V) to the positive row on the breadboard and connect the GND to the negative one on the breadboard.

Trouble shooting of Bluetooth issue:

Turn on the Bluetooth in your device.

Search for new device.

Click on Hc05 once it appear.

Enter the password "1234" or "0000".

Code for LCD 16x2 interface:

In Loop:

lcd.setCursor(0,1); // Sets the location at which subsequent text written to the LCD will be displayed //lcd.print("Distance: "); // Prints string "Distance" on the LCD

lcd.print(distance); // Prints the distance value from the sensor lcd.print(" cm ");

ANDROID APPLICATION The Android app developers generally use JAVA language, but this Android app can also build without knowing the Java language. This app inventor is specially designed for Block programmers those who don’t know the JAVA language. Main Screen:

Download Arduino code: https://drive.google.com/file/d/1VhK8YdduuUii37my...

Android app: https://drive.google.com/file/d/1VejZuFdf4gDLgAib...

Supplies

Download Arduino code: https://drive.google.com/file/d/1VhK8YdduuUii37myudvqCHzzVS8hwqCf/view?usp=sharing

Android app: https://drive.google.com/file/d/1VejZuFdf4gDLgAibmrERzBRLuqi2mVPD/view?usp=sharing

Block Code Contest

Participated in the
Block Code Contest

Be the First to Share

    Recommendations

    • One Board Contest

      One Board Contest
    • Fix It Speed Challenge

      Fix It Speed Challenge
    • Anything Goes Contest 2021

      Anything Goes Contest 2021

    Comments