Introduction: Simple Distance Measuring Device

Picture of Simple Distance Measuring Device

In this project we are going to learn how to use the HC-SR04 PING))) ultrasonic sensor to measure distance. This sensor is also often used on robots to detect obstacles.

Difficulty level: Easy

Time needed: ±10 minutes

Step 1: Things You'll Need

Picture of Things You'll Need

HC-SR04 PING sensor (x1)

Arduino UNO (x1)

LCD 16x2 (x1)

9V battery + dc adaptor (x1)

Potentiometer 10kΩ (x1)

Set of jumper wires

Step 2: Plug the PING Sensor and LCD

Picture of Plug the PING Sensor and LCD


GND (pin 1) to potentiometer (left pin)

VCC (pin 2) to potentiometer (right pin)

VO (pin 3) to potentiometer (center pin)

RS (pin 4) to arduino digital pin 12

RW (pin 5) to potentiometer (left pin)

E (pin 6) to arduino digital pin 11

D4 (pin 11) to arduino digital pin 5

D5 (pin 12) to arduino digital pin 4

D6 (pin 13) to arduino digital pin 3

D7 (pin 14) to arduino digital pin 2


left pin to arduino GND

right pin ro arduino 5V

PING Sensor

VCC to arduino 5V

Trig to arduino digital pin 7

Echo to arduino digital pin 6

9V battery

To arduino DC power socket

Step 3: Upload the Code

Picture of Upload the Code

Step 4: Have Fun! Show It to Your Friends :)

Picture of Have Fun! Show It to Your Friends :)

Yay! you have finished making your own measuring device. Now you can measure things without using a ruler! You can adjust the LCD brightness using the potentiometer. Feel free to give comments or ask questions and stay tune for my next project ; )


ManideepS1 (author)2017-02-20

Can u please make a how to make video

TaisH (author)2016-12-22

How will this react if the surface is not parallel? Can i read it then?

kenengineboy12 (author)2016-10-13

please i will like to get your contact, I need to discuss with you

Neiljams (author)2016-07-25

How can i get the LCD display to show the the distances more clearer? Mine seems to be pretty dark even with the 10k trim pot adjusted the best it can be.

nipon4666 made it! (author)2016-01-12

Good job.

nageshwararvi (author)2015-12-23

LCD display connection?
which is ping sensor here?

RishabhM18 (author)2015-12-09

I can connect phone in the place of LCD screen

RishabhM18 (author)2015-12-09

I can connect phone in the place of LCD screen

RishabhM18 (author)2015-12-09

I can connect phone in the place of LCD screen

ApoorvC1 (author)2015-11-22

Awsm bro

ApoorvC1 (author)2015-11-22

Awsm bro

laith mohamed (author)2015-09-02

Good work make it and its funny

anthonyjclarke (author)2015-06-27

Thanks, nice and easy!

Thanks :)

Safiul islam safi (author)2015-06-25

simple but useful too!
thanks for sharing :-)


akashs10 (author)2015-06-15

i have ir sharp sensor (range- 20cm-150cm).will it work instead of the ping sensor used here????

You can replace the ping sensor with your ir sensor, but you'll have to modify your code and the wiring. if you let me know your email I can help you :)
Pls reply soon

rampothineni (author)2015-06-15

up to how much distance it will measure

The hc-sr04 ultrasonic PING))) sensor can measure 2cm-400cm

navinr (author)2015-06-13

hey sam! is potentiometer really necessary?

Samuel_Alexander (author)navinr2015-06-13

Nope, you can replace the potentiometer with a resistor, but you must find the right resistance so the lcd contrast is not too high or too low.

If you are still confused, you can click the link below

Hope this helps ;)

irpan (author)2015-06-12

nice tutorial thank's for sharing :)

Samuel_Alexander (author)irpan2015-06-12

Thanks! I will post more projects soon :)

MohamedK13 (author)2015-06-12

thank you !!

Your welcome...

Electron_flow (author)2015-06-11

Thank you for sharing your project! Do you have a link to the full code? I've had difficulty getting consistency when using the Ping ultrasonic sensor, so I'd love to see what you're doing differently than i have been. Nice, easy to follow instructable, thanks again!

You can download my code from the bottom part of step 3. Hope this helps ;)

seamster (author)2015-06-10

Great tutorial! Nice and simple too. Very well done!


jallson (author)2015-06-10

Good Sam, good n simple instructables. video please

Samuel_Alexander (author)jallson2015-06-10

Thaks :)

Yep, I will post the video soon!

About This Instructable




Bio: I am Samuel Alexander, a 11th grade student at Cita-Hati High School in Surabaya, Indonesia. Since I was kid I have been interested in making ... More »
More by Samuel_Alexander:REAL 3D Wireframe Acrylic Table LampMeasuring Height Using Trigonometry (Measuring Tape Hack)Smart Home Power Strip
Add instructable to: