# Ultrasonic Distance Meter Using Arduino

In this tutorial, I will be able to show you the way to create an ultrasonic distance meter using Arduino. This project uses an HC-SR04 distance sensor and atmega328P or the other Atmega chip which is programmed using an Arduino programming kit, and the project is predicated on Arduino. But our final Circuit is a standalone circuit without the attached Arduino programmer.

## Components Required

• HC-SR04 Ultrasonic Sensor
• Arduino
• 16*2 LCD Display
• Jumper Wires
• 5V Power Supply

## Circuit Connection

LCD display to Arduino Nano setup connection

• Connect LCD pins 1, 3, 5,16 to the GND pin of Arduino Connect LCD pin 4 to the
• pin D7 of ArduinoConnect LCD pin 6 to pin D6 of ArduinoConnect LCD pin 11 to
• pin D5 of ArduinoConnect LCD pin 12 to pin D4 of ArduinoConnect LCD pin 13 to
• pin D3 of ArduinoConnect LCD pin 14 to pin D2 of Arduino
• Connect LCD pins 2, and 15 to the VCC(+5V) pin of the Arduino
• Connect HC-SR04 VCC pin to +5V pin of Arduino
• Connect HC-SR04 GND pin to GND pin of Arduino
• Connect the Trig pin to pin D9 of the Arduino
• Connect the Echo pin to pin D8 of the Arduino

## Working Principle of Ultrasonic Distance Meter

In this ultrasonic distance meter working principle, we can send a brief ultrasonic pulse at the trigger, and if any obstacles are there, the reflected received ultrasonic signal is converted to an electrical signal as an echo. If no obstacle is detected, the output pin will provide a 38ms high-level signal.

Here, we calculate the gap between the ultrasonic distance meter and any object before it. At t1 we send the trigger signal, and at t2 we get the echo signal

dt = (t2-t1)

The exact time taken by the sound to succeed in the item is: dt/2

Now, the Normal speed of sound is: 340 m/s

And after converting it to centimetres per microsecond it gives: 0.034049 cm/microsecond

The actual distance travelled by the sound or the gap between the sensor and also the object is:

Object = (dt/2) * 0.034049

By using this formula we can get the output of the actual distance of an object from an ultrasonic distance meter.

## Application of Ultrasonic Distance Meter

• To measure the distance of a specific object.