Distance measurement using ultrasonic sensor and Arduino:
Arduino distance measurement project has the number of applications that require to measure distance between two moving or stationary objects like water level measurement, distance measurement etc.
Ultrasonic sensors like HC-SR04 are widely used to measure the distance without actual contact.
- Arduino UNO
- 16×2 LCD
- HC-SR04 Ultrasonic Distance Sensor
- Connecting wires
Ultrasonic sensor HC-SR04
Interfacing HC-SR04 to a microcontroller is very much easy. trig pin is used to trigger an ultrasonic sensor and then “listen” for the echo pulse. The sensor measures the time required for the echo return, and returns this to the microcontroller as a variable pulse width via the echo pin.
- Precise, non-contact distance measurements
- Range 2 cm to 4 m range
- work in any lighting condition
- Requires just two microcontroller I/O pin
- Power requirements: +5 VDC;
The module works on the natural phenomenon of ECHO of sound. A high pulse is sent for about 10us to trigger the module. After which the module sends 8 cycles of 40 KHz ultrasound signal through transmitter and checks its echo received at receiver. By using this time span triggering pulse and echo you can calculate the distance by using formula as
Distance = (time x Speed)/ 2
Where speed= 340m/s (speed of sound wave or ultrasonic signal)
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.
Circuit Diagram (Arduino Distance measurement Project)
Ultrasonic sensor module’s
- “trigger” to A4of arduino
- “echo” to A5of arduino
- Vcc to 5V and
- Gnd to Ground of Arduino
16×2 LCD connected in 4-bit mode as
- RS – pin 2
- En–pin 3
- D4-D7 –pin 4- pin7
- RW, LED-, Vss– GND and Vdd, LED+ – 5V
#define trigger 18
#define echo 19
Let us know what you think about Arduino distance measurement in the comment section below, if you have new ideas on distance measurement using ultrasonic sensor and Arduino, please let us know.