Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Â
Arduino based distance measuring project
1. Arduino Based Distance Measure Box
Hello, in this project I will show you how to build your own distance meter box
with Arduino uno and one ultrasonic sensor.
Before starting, make sure that you have:
īˇ Arduino uno
īˇ HC-SR04 Ultrasonic Sensor
īˇ LCD 16x2
Official page: http://www.ardumotive.com/distance-measure-box.html
Video Link: https://youtu.be/KF4D6mv1vvk
Step 1: About HC-SR04 Ultrasonic Sensor
2. īˇ Ultrasonic Sensors
Ultrasonic sensors work on a principle similar to radar or sonar, which evaluate
attributes of a target by interpreting the echoes from radio or sound waves
respectively. Active ultrasonic sensors generate high frequency sound waves
and evaluate the echo which is received back by the sensor, measuring the time
interval between sending the signal and receiving the echo to determine the
distance to an object. Passive ultrasonic sensors are basically microphones that
detect ultrasonic noise that is present under certain conditions.
-----------------------------
īˇ HC-SR04
The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object
like bats or dolphins do. It offers excellent non-contact range detection with high
accuracy and stable readings in an easy-to-use package. From 2cm to 400 cm or
1â to 13 feet. It operation is not affected by sunlight or black material like Sharp
3. rangefinders are (although acoustically soft materials like cloth can be difficult to
detect). It comes complete with ultrasonic transmitter and receiver module.
īˇ Power Supply :+5V DC
īˇ Quiescent Current : <2mA
īˇ Working Currnt: 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
-----------------------------
īˇ Arduino Library
īˇ
Download and extract the HC-SR04 Library file to 'libraries' folder of Arduino ide
(see this video if you don't know how to find it)
īˇ ultrasonic_library.zip
DownloadStep 2: Breadboard Schematic
4. Tip!
If you want to control screen contrast put a 4.7k potentiometer at pin 3 of LCD
board instead ground cable.
Step 3: Code
Note: make sure that you have already install hc-sr04 library into Arduino ide
'libraries' folder.
//Libraries
#include
#include
//Setup connection with LCD and HC-SR04
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
Ultrasonic ultrasonic(A0,A1);
void setup() {
//Lcd init
lcd.begin(16, 2); //16 rows, 2 columns
}
void loop() {
lcd.clear();
lcd.print(" Ardumotive ;) "); // You can change this message.
lcd.setCursor(0, 1); //Change line...
lcd.print("Distance: ");
lcd.print(ultrasonic.Ranging(CM));
lcd.print("cm");
delay(1000); // 1sec delay
}
5. īˇ DistanceMeter.ino
Download
Step 4: Circuit and Box
I prefer to build my own Arduino based circuit and make my constraction smaller
than size of Arduino uno.
To build the box I used one sheet of balsa wood. Before you cut it make sure that
your circuit will fit in it.
Steps for success:
īˇ With a pen draw lines where you will cut the sheet
īˇ Cut the sheet with something... Balsa wood is very soft and can be easily
cut.
īˇ Put the Arduino uno (or your circuit) , LCD and HC-SR04 on already cut
sides
īˇ Final glue the box sides. (i used glue gun pistol)
If you want you can paint it! I paint it green with a marker ;)
7. Arduino Based Distance Measurement
using Ultrasonic Sensor
Arduino Based Distance Measurement using Ultrasonic Sensor
Ultrasonic sensors are great tools to measure distance without actual contact and used at
several places like water level measurement, distance measurement etc. This is an efficient
way to measure small distances precisely. In this project we have used an Ultrasonic
Sensor to determine the distance of an obstacle from the sensor. Basic principal of
ultrasonic distance measurement is based on ECHO. When sound waves are transmitted in
environment then waves are return back to origin as ECHO after striking on the obstacle.
So we only need to calculate the travelling time of both sounds means outgoing time and
returning time to origin after striking on the obstacle. As speed of the sound is known to us,
after some calculation we can calculate the distance.
8. Components Used
1. Arduino Pro Mini
2. Ultrasonic sensor Module
3. 16x2 LCD
4. Scale
5. Bread board
6. 9 volt battery
7. Connecting wires
Ultrasonic Sensor Module
Ultrasonic sensor HC-SR04 is used here to measure distance in range of 2cm-400cm
with accuracy of 3mm. The sensor module consists of ultrasonic transmitter, receiver and
the control circuit. The working principle of ultrasonic sensor is as follows:
1. High level signal is sent for 10us using Trigger.
2. The module sends eight 40 KHz signals automatically, and then detects whether
pulse is received or not.
3. If the signal is received, then it is through high level. The time of high duration is the
time gap between sending and receiving the signal.
Distance= (Time x Speed of Sound in Air (340 m/s))/2
9. Timing Diagram
The module works on the natural phenomenon of ECHO of sound. A pulse is sent for
about 10us to trigger the module. After which the module automatically sends 8 cycles of
40 KHz ultrasound signal and checks its echo. The signal after striking with an obstacle
returns back and is captured by the receiver. Thus the distance of the obstacle from the
sensor is simply calculated by the formula given as
Distance= (time x speed)/2.
Here we have divided the product of speed and time by 2 because the time is the total
time it took to reach the obstacle and return back. Thus the time to reach obstacle is just
half the total time taken.
10. 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.
First of all we need to trigger the ultrasonic sensor module to transmit signal by using
arduino and then wait for receive ECHO. Arduino reads the time between triggering and
Received ECHO. We know that speed of sound is around 340m/s. so we can calculate
distance by using given formula:
Distance= (travel time/2) * speed of sound
Where speed of sound around 340m per second.
A 16x2 LCD is used for displaying distance.
Find more about the working of distance measurement project in this tutorial: Distance
measurement using ultrasonic sensor.
Program Description
In code we read time by using pulseIn(pin). And then perform calculations and displayed
result on 16x2 LCD by using appropriate functions.
Code:
#include <LiquidCrystal.h>
#define trigger 18
#define echo 19
LiquidCrystal lcd(2,3,4,5,6,7);
float time=0,distance=0;
void setup()
{
lcd.begin(16,2);
pinMode(trigger,OUTPUT);
pinMode(echo,INPUT);
lcd.print(" Ultra sonic");
lcd.setCursor(0,1);
lcd.print("Distance Meter");
delay(2000);
lcd.clear();
lcd.print(" Circuit Digest");
delay(2000);
}
void loop()
{
lcd.clear();