Arduino based Distance Measure Box

Hello, in this project I will show you how to build your own distance meter box with Arduino uno and one ultrasonic sensor.

Before starting, make sure that you have:

  • Arduino uno
  • HC-SR04 Ultrasonic Sensor
  • LCD 16x2

    Watch video on YouTube!

    Step 1: About HC-SR04 Ultrasonic sensor

    Arduino based Distance Measure Box
    Arduino based Distance Measure Box
    Arduino based Distance Measure Box
  • Ultrasonic Sensors

    Ultrasonic sensors work on a principle similar to radar or sonar, which evaluate attributes of a target by interpreting the echoes from radio or sound waves respectively. Active ultrasonic sensors generate high frequency sound waves and evaluate the echo which is received back by the sensor, measuring the time interval between sending the signal and receiving the echo to determine the distance to an object. Passive ultrasonic sensors are basically microphones that detect ultrasonic noise that is present under certain conditions.


  • HC-SR04

    The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats or dolphins do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. From 2cm to 400 cm or 1" to 13 feet. It operation is not affected by sunlight or black material like Sharp rangefinders are (although acoustically soft materials like cloth can be difficult to detect). It comes complete with ultrasonic transmitter and receiver module.

  • Power Supply :+5V DC
  • Quiescent Current : Working Currnt: 15mA
  • Effectual Angle: Ranging Distance : 2cm - 400 cm/1" - 13ft
  • Resolution : 0.3 cm
  • Measuring Angle: 30 degree
  • Trigger Input Pulse width: 10uS
  • Dimension: 45mm x 20mm x 15mm


  • Arduino Library

    Download and extract the HC-SR04 Library file to 'libraries' folder of Arduino ide

    (see this video if you don't know how to find it)

    Arduino based Distance Measure Box
    ultrasonic_library.zip2 KB

    Step 2: Breadboard Schematic

    Arduino based Distance Measure Box


    If you want to control screen contrast put a 4.7k potentiometer at pin 3 of LCD board instead ground cable.

    Step 3: Code

    Note: make sure that you have already install hc-sr04 library into Arduino ide 'libraries' folder.



    //Setup connection with LCD and HC-SR04

    LiquidCrystal lcd(12, 11, 5, 4, 3, 2);

    Ultrasonic ultrasonic(A0,A1);

    void setup() {

    //Lcd init

    lcd.begin(16, 2); //16 rows, 2 columns


    void loop() {


    lcd.print(" Ardumotive ;) "); // You can change this message.

    lcd.setCursor(0, 1); //Change line...

    lcd.print("Distance: ");



    delay(1000); // 1sec delay


    Arduino based Distance Measure Box
    DistanceMeter.ino587 bytes

    Step 4: Circuit and box

    Arduino based Distance Measure Box
    Arduino based Distance Measure Box
    Arduino based Distance Measure Box

    I prefer to build my own Arduino based circuit and make my constraction smaller than size of Arduino uno.

    To build the box I used one sheet of balsa wood. Before you cut it make sure that your circuit will fit in it.

    Steps for success:

  • With a pen draw lines where you will cut the sheet
  • Cut the sheet with something... Balsa wood is very soft and can be easily cut.
  • Put the Arduino uno (or your circuit) , LCD and HC-SR04 on already cut sides
  • Final glue the box sides. (i used glue gun pistol)

    If you want you can paint it! I paint it green with a marker ;)

    Step 5: Distance measure test

    Arduino based Distance Measure Box
    Arduino based Distance Measure Box

    Watch video on YouTube!


    Tag cloud

    make build easy simple arduino making homemade solar laser printed portable cheap mini building custom cardboard wooden create super lego turn paracord chocolate your paper light intel