Distance Measuring Device




Introduction: Distance Measuring Device

About: I am an electronic hobbyist on Arduino, Photon, Raspberry Pi and common electronics.A passionate cook.Any assistance in electronics and web development feel free to contact me at appytechie.at@gmail.com.

Hey, Guys, I'm Sridhar Janardhan back with another tutorial.This time I am going to teach you how to create your own distance measuring instrument under 10$.I have tried my best to keep this ibles very simple so even a beginner can crack it down.This ibles needs a sensor called ultrasonic sensor whose operation will be explained in the later part of the ibles.So now let's start to gather the components.

Step 1: Components Required:

The components required for this tutorials are:

  • Arduino Uno
  • Jumper wire
  • Ultrasonic sensor
  • LCDI2cBreadboard

Step 2: HC-05 Ultrasonic Sensor:

The HC-05 Ultrasonics sensor is a device that is designed to measure the distance of an obstacle placed in front of them.it has two eye-like things the echo and trig.The echo pin emits a wave that travels through the medium and reflects back as soon as it hits the obstacles.The reflected wave triggers the trig pin, The time taken between the emitting and triggering the trig pin is calculated to estimate the distance between the sensor and the object.

Pin description of the HC-0s sensor:

  • TRIG pin: This pin triggers the sensor and sends a control signal indicating the conveying of the objects.
  • VCC pin: The positive power supply is given to this pin.
  • GND pin: the Grounded power supply is given to this pin.
  • ECHO pin: The pin that is used to send the wave into the medium

Pin connection as follows:

  • TRIG pin: digital pin 13
  • ECHO Pin: digital pin 12
  • VCC pin:Positive railing of the breadboard
  • GND pin:Negative railing of the breadboard

Let's now connect the LCD.

Step 3: Connecting LCD:

I have soldered I2C TO lCDto make the connection easy.

To know the tutorial on how to connect I2C to LCD please click here

The connection of LCD is as follows:

  • The SDA pin to Arduino analog pin A0.
  • The SDL pin to Arduino analog pin A1.
  • The VCC pin to the positive railing of the breadboard.
  • The GND pin to the negative railing of the breadboard.

Let's get into coding

Step 4: Coding


LiquidCrystal_I2C lcd(0x3f, 16, 2);

void setup() {



} void loop() {

lcd.setCursor(0, 0);

lcd.print("time: ");


lcd.print(" us ");

lcd.setCursor(0, 1);

if( duration > 38000 ) {

lcd.println("out of reach ");

} else {

lcd.print("dist: ");


lcd.println(" cm "); }



Step 5: Output

Makerspace Contest 2017

Participated in the
Makerspace Contest 2017

Be the First to Share


    • Make it Glow Contest

      Make it Glow Contest
    • Clocks Contest

      Clocks Contest
    • Baking Contest

      Baking Contest



    11 months ago

    What is the below line? - is this shows the time ?
    Can it shows Inches and CM both measures?

    What is the minimum and maximum distance
    lcd.print("time: ");
    lcd.print(" us "); -


    Question 3 years ago on Introduction

    What is the maximum distance in feet that it can measure? I need to measure an industrial gate that travels vertical a distance up to 10 feet but makes incrimental stops along the travel.


    5 years ago

    Love the project, thank you. I've been thinking of something similar for my bike. Would its response time be quick enough to capture the distance of a car passing from behind? What's the maximum distance it picks up from? I'm assuming it could be coulpled with a logger of some sort where you cold retrieve the data at a later time.


    Reply 5 years ago

    Just talking from experience with mine:

    The max distance i ever recorded was around 4-5m.

    It has fairly quick response time, microseconds.

    Hope it helps you!


    Reply 5 years ago

    Thanks, that's far enough (about 1m is law, so I'm more interested in who's closer than that.)