Ultrasonic Sensor with Arduino

In this tutorial, we learn how to measure the distance by using the Ultrasonic Sensor with Arduino. We also use an LCD 16×2 Display to show the distance.

An ultrasonic sensor is used to measure the distance to an object using sound waves. It provides measurements of the time that takes the sound to fling something and return it to the sensor. Read More

It works on sound wave frequency like sonar. The ultrasonic sensor also cannot detect some objects.

HC-SR04 ultrasonic can measure a range of 2 cm to 400 cm (4 m).

ultrasonic sensor

This sensor has 2 openings on its front. One is the transmitter which transmits ultrasonic waves like a speaker and the other is a receiver that receives them like a microphone.


Components List


Pin Connections

Ultrasonic PinsArduino Pins
5v or Vin5V
GNDGND
Trigger9
Echo8

Circuit Diagram for Ultrasonic Sensor With Arduino

Circuit Diagram of Ultrasonic Sensor With Arduino

Code For Ultrasonic Sensor Arduino

Output

Output of Ultrasonic Sensor with Arduino

Ultrasonic Sensor and LCD 16×2 with Arduino

Now we are displaying the distance reading (sensor values) of the ultrasonic sensor on an LCD Display 16×2.

Read More about LCD 16×2:

Pin Connections of LCD 16×2 with Arduino

Pin No.LCD PinsArduino Pins
1VSS/GNDGND
2VDD/VCC5v
3V0Potentiometer Vout
4RS12
5RWGND
6E11
7-10D0-D3No connection
11D45
12D54
13D63
14D72
15A/LED+5v
16K/LED-GND

Circuit Diagram of Ultrasonic Sensor and LCD

distance measurement using ultrasonic sensor and arduino with lcd display

Code

Output

output of ultrasonic sensor with arduino

Here some more tutorials for you:

Scroll to Top