Ultrasonic Sensor Distance Measuring
Ultrasonic Sensor Distance Measuring
Ultrasonic Sensor Distance Measuring
Project Presentation
Group Members:
Muhammad ilyas (UET/SCET-16F-ME-005)
Junaid Adil (UET/SCET-16F-ME-001)
Yasir Usman (UET/SCET-16F-ME-018)
Fahad Ali (UET/SCET-16F-ME-043)
Ijaz
ul Hassan (UET/SCET-16F-ME-047)
Outlines
1. Introduction
2. Components used in this project
3. Detail of components
4. Arduino Coding
5. Circuit Design(Block diagram)
6. Working of project
7. Application & use
8. Conclusion
1. INTRODUCTION:-
• A range finder is a device used to find the distance from a point to
the nearest obstacle. This device uses ultrasonic technology to
measure the distance. You can consider it like an electronic, hassle-
free version of a measuring tape with a measuring range of 2cm to
400cm and an accuracy of 1cm.
1 Vcc The Vcc pin powers the sensor, typically with +5V
2 Trigger Trigger pin is an Input pin. This pin has to be kept high
for 10us to initialize measurement by sending US wave.
3 Echo Echo pin is an Output pin. This pin goes high for a
period of time which will be equal to the time taken for
the US wave to return back to the sensor.
Accuracy: 3mm
This sensor is a very popular sensor used in many applications where measuring distance or sensing objects
are required. The module has two eyes like projects in the front which forms the Ultrasonic transmitter and
Receiver. The sensor works with the simple high school formula that
The Ultrasonic transmitter transmits an ultrasonic wave, this wave travels in air and when it gets objected by
any material it gets reflected back toward the sensor this reflected wave is observed by the Ultrasonic
receiver module as shown in the picture below.
HC-SR04 Ultrasonic Sensor - Working
Since we are using the Ultrasonic wave we know the universal speed of US wave at room conditions
which is 330m/s.
The circuitry inbuilt on the module will calculate the time taken for the US wave to come back and
turns on the echo pin high for that same particular amount of time, this way we can also know the
time taken.
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
const int trigPin = 11;
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
const int echoPin = 10;
const int led = 13;
duration = pulseIn(echoPin, HIGH);
long r = 3.4 * duration / 2;
float distance = r / 100.00;
void setup()
{
lcd.setCursor(0, 1);
pinMode(trigPin, OUTPUT);
lcd.print(distance);
pinMode(echoPin, INPUT);
delay (300);
pinMode(led, OUTPUT);
lcd.begin(16, 2);
lcd.print ("Ultrasonic ");
lcd.setCursor(0, 1);
if(distance<10)
lcd.print ("Range Meter");
{
delay (5000); Compiling the Code
digitalWrite(led,HIGH);
}
}
else
long duration, r;
{
float distance;
digitalWrite(led,LOW);
}
void loop()
Then Arduino Programming will
{
delay(300); complete and save in Arduino.
}
5.CIRCUIT DESIGN:-
•The circuit consists of Arduino Uno, which is the brain of the project, an Ultrasonic sensor and an LCD display to instantaneously
display the results. The design of the circuit is very simple and is explained below.
•Of the available 14 I/O pins on Arduino, we use 8 pins in this project. 2 pins are used for Ultrasonic sensor and other 6 pins are
used to control the LCD.
•The 4 pins of Ultrasonic sensor are Vcc, Gnd, Trig and Echo. Trig is connected to Pin 11 of Arduino and Echo is connected to Pin
10. With respect to Arduino, Pins 10 and 11 are input and output respectively.
•Pins 15 and 16 (LED+ and LED-) of the LCD are backlight pins. They are connected to Vcc and Gnd respectively (not shown in
circuit diagram).
•Four data pins of LCD are used to display the information. Pins 11, 12, 13 and 14 of LCD (D4 – D7) are connected to pins 5, 4, 3
and 2 of Arduino.
•Pins RS and E (pins 4 and 6) of LCD are connected to pins 7 and 6 of Arduino respectively while RW (pin 5) is connected to
ground.
•Pins 1 and 2 (Vss and Vdd) are connected to ground and Vcc respectively. In order to control the contrast of the LCD display, pin
3 (VE) of LCD is connected to the wiper of a 10 KΩ POT with the other terminals of POT connected to Vcc and Gnd.
Block Diagram of Ultrasonic Range Meter
6. WORKING:-
• Ultrasonic sensor is the main module in the range meter circuit. An ultrasonic sensor consists of an
ultrasound transmitter and a receiver. The transmitter sends a sonic burst of 8 pulses at 40 KHz frequency.
• This signal hits the target and the echo is received by the receiver module. By measuring the time
between the events of sending the pulse and receiving the echo, the distance can be calculated.
• The ultrasonic sensor used in this project is HC-SR04. It can be used to measure distance in the range of
2cm to 400cm with accurate readings. The sensor module consists of 4 pins: Vcc, Gnd, Trig and Echo.
When the Trig pin is high for a duration of at least 10µs, the ultrasonic sensor sends the ultrasound
signals. The Echo pin is high from the moment of sending the signal and receiving it.
• This duration for which the Echo signal is high is calculated by Arduino as per the code and is converted to
distance in centimetres. The same data is displayed on the LCD.
• Arduino continuously sends the Trig signal and the distance of the target can be measured continuously
without any delay.
• As the power requirement of the circuit is very less, the whole system can be powered by a 9V battery
and can be used as a Portable Range Meter.
How distance calculate by US Sensor using
Microcontroller