Build a Height Measurement Machine – Arduino

Hi guys, I am sure you all have seen height measuring machines in shopping malls. Unfortunately, it is rarely used because you gonna have to pay for it :D. But no worries, with a little bit of patience we can build our own height measurement machine, we can learn the science behind it and gain experience in DIY. 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 it transmitting a 40khz sound wave and let it bounce on a solid surface. The other one will try to detect the echo that is generated when it receives the bounce back. The total time taken for this process to complete will give us the distances between the sensor and the object.



In order to build the height measuring machine, we will need to place the ultrasonic sensor on something that is tall and  the sensor will need to be facing down. You will need to calibrate the sensor by making sure that nothing is blocking it from the floor and pressing a push button. It may sound complicated, but it will make sense once you build it. 🙂


Part List

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


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

Hook it up!

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 can’t find ultrasonic sensor on Fritzing so instead I use this method. 😀
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 tall place.

Build Height Measurement Machine

Upload the code

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.                                                                                     IMG_20150425_180032 IMG_20150425_180112IMG_20150425_180148

 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 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! 🙂



, , ,

Related Post

Getting Started with Colour Sensor Module (SN-COLOUR-MOD)

Getting Started with Tilt Sensor (SN-TILT)

Getting Started with Vibration Sensor Module (Normally Off) (SN-VIBRATE-MOD)

Getting Started with IR Distance Click

8 thoughts on “Build a Height Measurement Machine – Arduino

  1. 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.

  2. 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.

  3. 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?

  4. 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…

Leave a Reply

Your email address will not be published. Required fields are marked *