Ultrasonic Sensor Distance Calculation
Ultrasonic Sensor Distance Calculation
Ultrasonic Sensor Distance Calculation
by
SATHYABAMA
INSTITUTE OF SCIENCE AND TECHNOLOGY
(DEEMED TO BE UNIVERSITY)
Accredited with Grade “A” by NAAC
JEPPIAAR NAGAR, RAJIV GANDHI SALAI, CHENNAI - 600 119
APRIL 2023
1
DEPARTMENT OF ELECTRICAL AND ELECTRONICSENGINEERING
BONAFIDE CERTIFICATE
2
DECLARATION
who hereby declare that the project entitled “DISTANCE MEASUREMENT USING
ULTRASONIC
DATE: 20.04.2023
PLACE: Chennai
3
ACKNOWLEDGEMENT
We would like to express our sincere and deep sense of gratitude to our Project Guide
Mrs.D.Ramya for her valuable guidance, suggestions and constant encouragement
paved way for the successful completion of our project work.
We wish to express our thanks to all Teaching and Non-teaching staff members of the
Department of Electrical and Electronics Engineering who were helpful in many ways
for the completion of the project.
4
Abstract
The News reports estimates that 1 in 5 car accidents occur in the
parking lot. It may be a head-on, rear-end, or T-bone crash. Since
these occur in the parking lot, the vehicle's speed is low, and
possibly the passengers remain safe.But in some circumstances,
they could be fatal.
Studies say parking accidents are mostly due to drivers'
distractions caused by using mobile phones.
In a parking lot, pedestrians move freely, and the driver has to
remain alert even about their blind spots.
We designed a system using the ultrasonic sensor that could be
deployed in an Vehicle. The ultrasonic sensor is used to detect
objects in blind spots.
A blind spot is an area in close proximity to the vehicle where the
driver has low or zero visibility.
The ultrasonic sensor works similarly to bats. Like bats, the
ultrasonic sensor transmits ultra-frequency waves and measures
the distance of the obstacle from the vehicle.
These sensors can accurately detect objects and don't require
any lighting. When the object is very close, it could signal the
driver to become alert. Thus, it assists drivers in moving safely in
a parking lot.
5
TABLE OF CONTENT
2 Literature Survey 14
3 PROJECT DESCRIPTION
3.1 Existing Methodology 17
3.2 Proposed Methodology 18
3.3 Block Diagram 19
6
4.1.3 Ultrasonic sensor(HC-SR04) 23
4.1.3.1 Ultrasonic sensor module 24
4.1.3.2 Timing Diagram 24
4.1.4 16x2 LCD 12C display 26
4.1.5 10K potentiometer 27
4.1.6 Servomotor 28
4.1.7 Resistor(220ohm) 29
4.1.8 Bread board 29
4.2 Hardware Connection 30
4.3 Simulation Model 31
4.4 Arduino Program 32
4.5 Simulation Output
using tinkercad software 36
4.6 Arduino IDE program Execution 37
7
List of figures
Figure No . TITLE PAGE NO.
4.1.1 Jumper wires 20
4.1.2 Aurdino UNO R3 Board 21
4.1.3 Ultrasonic Sensors 21
4.1.3.2 Timing Diagram 25
4.1.4 16x2 LCD Display 26
4.1.5 10K Potentiometer 27
4.1.6 Servomotor 28
4.1.7 220 Ohm Resister 29
4.1.8 Breadboard 29
4.3 a Circuit Diagram 31
4.3 b Simulation Model 31
4.5 Simulation Output 37
8
List of tables
9
CHAPTER 1
INTRODUCTION
10
The concept of distance measurement has been around for centuries, with
early civilizations using primitive methods such as pacing, ropes, and
sticks. However, with the advancements in technology, we now have
access to sophisticated instruments that can measure distances with high
precision and accuracy.
11
Moreover, this technology can also be used in agriculture for crop
monitoring, in sports for measuring ball speed and trajectory, and in
education for teaching basic principles of physics and electronic
already exist?
12
1.4 Motivation of the project:
Our main moto is to reduce the blindspot accidents.
13
CHAPTER 2
14
vice-versa. These sound waves are in the frequency range of 20000hz
which is beyond the hearing range of humans therefore only the sensor
can detect them. First, they identified that signal processing is easier
because the speed of sound is slower than the speed of light in the
presence of air. Second, the relatively short ultrasonic wavelengths allow
for a “more highly accurate distance measurement , therefore measuring
the distance from such objects does not affect the measurements. Finally,
ultrasonic is not affected by the effects of light and airborne dusts, allowing
it to perform measurements of distance in outdoor environments. To
elaborate, another paper on the use of ultrasonic sensor with the inclusion
of Arduino by Soni et al. (2017) explains the theory of sound waves.
According to the authors, “Sound waves are defined as longitudinal
pressure waves in the medium in which they are travelling. Subjects
whose dimensions are larger than the wavelength of the impinging sound
waves reflects them, the reflected waves are called the echo. If the speed
of sound in the medium is known and the time taken for the sound waves
to travel the distance from the source to the subject and back to the source
is measured, the distance from the source to the subject can be computed
accurately”.A similar study on the use of ultrasonic sensor for distance
measurement was also done by Ratan and Luthra (2015). They also
applied the use of an ultrasonic sensor for distance measuring due to its
versatility and applicability in so many fields. Their objective was to create
a low cost simple device with acceptable accuracy. Although they have
met the objective of the project, the limitations they found on their project
was the need to orient the device perpendicularly to the “plane of
propagation of the ultrasonic waves .Another similar study of an ultrasonic
sensor for distance measurement was also done by Abdullah (2015).
They used an ultrasonic sensor (particularly the HC-SRO4) for their study,
it is because they found out that this material is to be the “most reliable
15
and inexpensive method for distance measurement”. But in their case, a
temperature compensator was added to their system to compensate for
the errors that may possibly occur due to the ambient temperature. The is
because the speed of ultrasonic wave is affected by the “type of medium
and the temperature”.The researchers may consider the addition of a
temperature compensator if temperature has a substantial effect on the
device’s capabilities and if it restricts its effectivity in the places where it is
expected to be used.Carullo, A., & Parvis, M. (2001). An ultrasonic sensor
for distance measurement in automotive applications. IEEE Sensors
journal, 1(2), 143. As ultrasonic sensors have a wide application in the
field, in a paper published by Carullo and Parvis (2001), they mounted an
ultrasonic sensor to measure the distance between the ground and the
bottom of the car. Their purpose was to get the height of the car from its
bottom surface to the ground with goal of satisfying the requirements in
the automotive field. Their experiment was a success and it exemplifies
the versatility of an ultrasonic sensor in various fields.With regards to
distance measurement, another electromagnetic device patented by Woo
and Lien (1979) works similarly to that of the researchers’ device.
Although the major difference is that they are using an optical sensor for
distance
measurement and not an ultrasonic sensor. But their device also has a
display capable of showing the resulting measurements. The display can
show the measurements according to the preference of the user: in
centimeters, inches, or meters. The researchers would like to include
something similar by providing two units of measurements in the display.
A combination of centimeters and inches which are both the most widely
used units in measuring distance worldwide.
16
CHAPTER 3
PROJECT DESCRIPTION
17
To implement this project, we will need an Arduino board, ultrasonic
sensors, jumper wires, and a power source. The ultrasonic sensors
will be mounted on the front and back bumpers of the vehicle, and
connected to the Arduino board through jumper wires. Once the
hardware is set up, we will write a program code that controls the
sensors and processes the distarice the measurements. The
program will use algorithms to calculate the distance between the
vehicle and nearby objects, and display the results on a screen or
through audio feedback.The use of ultrasonic sensors and Arduino
boards in vehicle applications has a wide range of potential
applications beyond just parking and collision avoidance.
18
3.3 BLOCK DIAGRAM :
. Fig:3.3.1
The ultrasonic sensors will be mounted on the front and back bumpers of
the vehicle, and connected to the Arduino board through jumper wires..
Arduino will receive the data from the ultrasonic sensor and process it to
calculate the distance between the vehicle and the obstacle. In addition
to processing the data, the Arduino board will also be responsible for
providing feedback to the driver through various output devices such as
speakers or LED lights. In this project we have used buzzer to alert the
driver.
19
CHAPTER 4
HARDWARE AND SIMULATION
Fig: 4.1.1
20
4.1.2 ARDUINO UNO R3 BOARD:
Arduino Uno is a microcontroller board based on the
ATmega328P (datasheet). It has 14 digital input/output pins (of which 6
can be used as PWM outputs), 6 analog inputs, a 16 MHz ceramic
resonator (CSTCE16M0V53-R0), a USB connection, a power jack, an
ICSP header and a reset button.
The Arduino UNO is the best board to get started with electronics and
coding. If this is your first experience tinkering with the platform, the UNO
is the most robust board you can start playing with. The UNO is the most
used and documented board of the whole Arduino family.
Fig:4.1.2
21
4.1.2.1 PIN DETAILS – ARDUINO UNO
22
4.1.3 ULTRASONIC SENSORS
Ultrasonic sensors are great tools to measure distance and detect objects
without any actual contact with the physical world. It is used in several
applications, like in measuring liquid level, checking proximity and even
more popularly in automobiles to assist in self-parking or anti-
collision systems.
Fig:4.1.3
The speed of the sound is known to us, after some calculation we can
calculate the distance. We are going to use this same technique for
this Arduino distance measurement project.
23
4.1.3.1.Ultrasonic Sensor Module:
There are many types of Arduino distance sensors, but in this project we
have used the HC-SR04 to measure distance in range of 2cm-400cm with
an accuracy of 3mm. The sensor module consists of an ultrasonic
transmitter, receiver and control circuit. The working principle of ultrasonic
sensor is as follows:
24
Fig:4.1.3.2
This is a 16x2 LCD display screen with I2C interface. It is able to display
16x2 characters on 2 lines, white characters on blue background. These
displays are mainly preferred for multi-segment light-emitting diodes and
seven segments. The main benefits of using this module are inexpensive;
simply programmable, animations, and there are no limitations for
displaying custom characters, special and even animations, etc.
25
Fig:4.1.4
Usually, Arduino LCD display projects will run out of pin resources easily,
especially with Arduino Uno. And it is also very complicated with the wire
soldering and connection. This I2C 16x2 Arduino LCD Screen is using an
I2C communication interface. It means it only needs 4 pins for the LCD
display: VCC, GND, SDA, SCL. It will save at least 4 digital/analog pins
on Arduino. All connectors are standard XH2.54 (Breadboard type). You
can connect with the jumper wire directly.
26
4.1.5 10K POTENTIOMETER
The 10K Potentiometer is used for adjusting various parameters
like voltage, current, etc in an electronic circuit. The POT
Potentiometer is a passive electronic component that has two end
terminals with a resistive element and the sliding contact called the wiper
acts as the third terminal.It is mostly used in application where a single
turn can provide enough control resolution.
Fig:4.1.5
Table:4.1.5
27
4.1.6 Servo motor
Servo motors are electronic devices and rotary or linear actuators that
rotate and push parts of a machine with precision. Servos are mainly
used on angular or linear position and for specific velocity, and
acceleration.
Fig:4.1.6
28
4.1.7 220 Ohm resistor
The 220 Ohm resistor can be identified via resistor color codes of Red-
Red-Brown-Gold or Red-Red-Black-Black-Gold
Fig:4.1.7
4.1.8 Breadboard
Fig:4.1.8
29
4.2 HARDWARE CONNECTIONS:
The circuit diagram for arduino and ultrasonic sensor is shown
above to measure the distance. In circuit connections Ultrasonic sensor
module’s “trigger” and “echo” pins are directly connected to pin 18(A4)
and 19(A5) of arduino. A 16x2 LCD is connected with arduino in 4-bit
mode. Control pin RS, RW and En are directly connected to arduino pin
2, GND and 3. And data pin D4-D7 is connected to 4, 5, 6 and 7 of arduino.
The time taken for the sound wave to propogate from transmitter to
receiver is proportional to the distance of the object. In this distance
measurement system we had ultrasonic sensor HC-SR04 interfaced with
Arduino UnoR3. Programming and hardware part of ultrasonic sensor
interfacing with Arduino UnoR3.servo motors are used to control the
position of objects, rotate objects, move legs, arms or hands of robots,
move sensors etc. with high precision. Servo motors are small in size, and
because they have built-in circuitry to control their movement, they can be
connected directly to an Arduino.
Where speed of sound around 340m per second. A 16x2 LCD displaying
distance
30
4.3 Simulation Model :-
Fig: 4.3a
Fig:4.3 b
31
4.4 ARDUINO PROGRAM:
#include <LiquidCrystal.h> //LCD library
#include<Servo.h> //Servo library
#define echo 2
#define trig 3
#define Buzzer 7
void setup() {
myservo.attach(6); // Servo is connected to Digital pin 6
pinMode(trig, OUTPUT);
pinMode(echo, INPUT);
pinMode(Buzzer,OUTPUT);
Serial.begin(9600);
lcd.begin(16, 2);
32
void loop() {
for (int i = 0; i <= 180; i++) {
myservo.write(i);
time_Measurement();
distance = duration * (0.0343) / 2;
if (distance <= scan_Distance) {
intruder_detected();
}
else {
lcd.clear();
lcd.print("Scanning...... ");
}
delay(100);
}
for (int i = 180; i >= 0; i--) {
myservo.write(i);
time_Measurement();
distance = (float)duration * (0.0343) / 2;
if (distance <= scan_Distance) {
intruder_detected();
}
else {
lcd.clear();
lcd.print("Scanning...... ");
}
delay(100);
33
}
}
void time_Measurement()
{
digitalWrite(trig, LOW);
delayMicroseconds(2);
digitalWrite(trig, HIGH);
delayMicroseconds(10);
digitalWrite(trig, LOW);
void intruder_detected()
{
lcd.clear();
lcd.setCursor(0, 0);
lcd.print(" Intruder at ");
lcd.setCursor(0, 1);
lcd.print(" ");
lcd.print(distance);
lcd.print(" cm");
digitalWrite(Buzzer, HIGH);
delay(3000);
digitalWrite(Buzzer, LOW);}
34
4.5 Simulation Output using Tinkercad software:
Fig: 4.5 a
Fig: 4.5 b
35
4.6 AURDINO IDE PROGRAM EXECUTION:
36
CHAPTER 5
CONCLUSION AND FUTURE SCOPE
Distance measurement using ultrasonic sensors and Arduino is a popular
research area with various applications. The results of this review indicate that
ultrasonic sensors and Arduino are widely used in the development of
electronic projects related to distance measurement. Further research is
needed to explore the potential of these technologies in various other
applications
Distance =speed*time
The human audible range can be converted measure the distance precisely
manner
FUTURE SCOPE
References
[1] .Arefin Shamsul MD., & Mollick Tajrian (2013). Design of an
Ultrasonic Distance Meter. International Journal of Scientific &
Engineering Research Volume 4, Issue 3
[2].M. Rüeger, J. (1980). Recent developments in electronic distance
measurement. Australia Surveyor30.10.1080/00050326.1980.10442489.
[3]. Czajkowski, S. B. (1984). U.S. Patent No. 4,464,738. Washington,
DC: U.S. Patent and Trademark Office.
[4].Hils, T. (2010). U.S. Patent No. 7,643,927. Washington, DC: U.S.
Patent and Trademark Office. Win, L. A., & Lam, W. C. W. (1988). U.S.
Patent No. 4,730,190. Washington, DC: U.S. Patent and Trademark
Office.
37