Build a Height Measurement Machine – Arduino

Hi guys, I am sure you all have seen height measuring machines in shopping malls. Unfortunately, they are rarely used because you have to pay to use it :D. But no worries, with a little bit of patience we can build our own height measuring machines, learn the science behind it and gain some DIY experience.
This tutorial is split into 4 sections : Theory, Parts list, Hands-on, Troubleshoot.



We will be using Ultrasonic Sensor to measure the height. Ultrasonic contains two round looking component which are ultrasonic speakers. One of transmits a 40khz sound wave that will bounce (echo) back upon hitting a solid surface. The other one detects the echo. By measuring the total time taken for this process, we can measure the distances between the sensor and the object.



To build the height measuring machine, the ultrasonic sensor will need to be place up high with the sensor facing down. We make sure that nothing is blocking the sensor from the floor, and calibrate the sensor by pressing a button. It may sound complicated, but it will make sense once you build it. 



You will need the following items for building the height measurement machine:


Now that we got our items ready. Let’s get to work~


This is a very complicated circuit. The four wires that are connected to Vcc, Trigger, Echo and Gnd are the pins on the ultrasonic sensor. I couldn’t find ultrasonic sensor on Fritzing so instead I only drew the pinouts 
Please use Male to Female wire for LCD and ultrasonic sensor connection (Connections in red and green). It will make it easier to attach the LCD and ultrasonic sensor to a distant, tall place.

Build Height Measurement Machine


Here is the code. Please download the NewPing library from this link.  If you are unfamiliar with installing library, do refer to this link.

[code lang=”c” highlight=””]
#include <NewPing.h>
#include <LiquidCrystal.h>
#define TRIGGER_PIN 13
#define ECHO_PIN 12
#define MAX_DISTANCE 500
int val = 0;
int val2 ;
LiquidCrystal lcd(6,7,8,9,10,11);
void setup() {

void loop() {
unsigned int uS =;
if(digitalRead(5) == HIGH & val <= 0){
val2 = uS/ US_ROUNDTRIP_CM ;

if(digitalRead(5) == LOW & val <= 0){ lcd.print(“Waiting for”); lcd.setCursor(0,1); lcd.print(“Calibration”); } if(digitalRead(5) == LOW & val >= 1){
lcd.print(val2 – uS / US_ROUNDTRIP_CM);

if(digitalRead(5) == HIGH & val >= 1){
lcd.print(val2 -uS / US_ROUNDTRIP_CM);

void plus(){
val = val + 1;


Once you upload the source code, you should see “Waiting for Calibration” on your LCD. If you can’t see it, adjust your variable resistor. If it is still not there, check your wiring. There are many wires in this project, so take sometime to do some troubleshooting.


You can build your own tall structure with impra board or wood but I recommend installing it on your cupboard or anywhere tall. It will save cost and make your cupboard look cool!


However, one problem that you will face is that due to the vast range of the ultrasonic sensor, the ultrasound may fall onto the side of your cupboard.


To solve this problem, you will have to move the ultrasonic sensor further away from the edge.


You can build a “bridge” to support the ultrasonic sensor. Basically, you can do it by using the Cytron’s box which contain everything you order from cytron. Cut out the front flap and you can use it as a bridge.                                                                                      

 Then, tape the bridge along with the ultrasonic sensor to it .Now that you got everything ready. You are ready to start measuring height!


First, press the reset button on the Arduino Uno. This will return to calibration mode. Then make sure that nothing is below the ultrasonic sensor. Make sure your ultrasonic sensor can see the floor. Then press the push button connected to pin 5, the LCD will display the height of the object below it. And that’s it, you did it!



I know that this is an extremely complicated circuit because the LCD require a lot of wiring. But what’s the big rush? You’ve got the luxury of time to troubleshoot it. 

– Comfirm that your wiring are according to my fritzing photo.

– Make sure your 9V Battery is producing 9v. Check it using a multimeter.

– Make sure you did not reverse your 9v Battery’s polarity.

I am still a beginner in creating tutorials. If you experience any problem, do not hesitate to post it in the forum. I will be very glad to help you! 


16 thoughts on “Build a Height Measurement Machine – Arduino”

  1. enda punda when i copy this code and put it in a compiler i have a compile error can you clear that error

  2. Please send me the circuit diagram. Thanks in anticipation. Looking forward to hearing from you.

  3. Hey actually I am student and I want to know something, what type of sensors are used for measuring the height of a object,if there are multiple obstacles ( fabric materials/leather like materials) in front of the sensors.

  4. Hi how can i measure height using push button?
    1. LCD = “Push button to know your height”
    2. Get Height
    3. LCD = “Your Height is ## cm”

    then again push button for the next person to check the height

  5. Hi i Want a Project tutorial that calculate
    The Height of obstacles that i fixed..if It detect different size of Height It should Send MSG using GSM module…

  6. I’d like to measure human heights in clinic. Is this sensor sensitive to hair? I mean it is important to measure exact height in this case which requires measuring height till the end of skull also to prevent error occurs by hair. I mean height shouldn’t be dependent to hairstyle. can this sensor help me?

  7. Hi, the ranging Distance of this sensor is 2cm – 400 cm or 1″ – 13ft. We cannot adjust the distance of this sensor because it is fixed. But inside the coding we can. Its depend on you.

  8. Hey how can I adjust the max_distance ?
    Your max_distance means “16.66 ft”?
    Please answer me as quickly as possible.
    And thanks a lot.

Leave a Comment

Your email address will not be published.

Share this Tutorial

Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest
Share on facebook
Share on whatsapp
Share on email
Share on print
Share on twitter
Share on pinterest

Latest Tutorial

DIY Digital Alarm Clock Using REKA:BIT With Micro:bit
Display Internet Time (NTP) on micro:bit
DIY Interactive Robot Using REKA:BIT With Micro:bit
BLTouch Installation for Ender 3 with 32-bit V4.2.2 Board
Pick and Send Random Meal’s Option and Locations through Telegram Bot Using Grove WiFi 8266 on micro:bit
Tutorials of Cytron Technologies Scroll to Top