Bukit Mertajam, Penang

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.

20150425_181259

Theory

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.

 

ultrasonicultrasonic

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

CalibrateHuman

Part List

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

Hands-on

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

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 ;
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
LiquidCrystal lcd(6,7,8,9,10,11);
void setup() {
lcd.begin(16,2);
pinMode(5,INPUT);
}

void loop() {
lcd.home();
unsigned int uS = sonar.ping();
if(digitalRead(5) == HIGH & val <= 0){
plus();
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);
lcd.print(“cm”);
delay(100);

}
if(digitalRead(5) == HIGH & val >= 1){
lcd.print(val2 -uS / US_ROUNDTRIP_CM);
lcd.print(“cm”);
delay(100);

}
delay(100);
lcd.clear();
}
void plus(){
val = val + 1;
}

[/code]

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.

Structure

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!

cupboard

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.

wrong

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

cupboard

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!

20150425_181344

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!

20150425_181259

Troubleshooting

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

 

Buy

Related Posts

Comments (13)

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.

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.

Do you have a picture of your finished project from the top? If you do, can you send it to seijuroshin2113@gmail.com ? Thank you

how we can display height though three
8 segmented dispaly

Hi, this is the example only, Maybe you can go to our technical forum and discuss there 🙂

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?

Please send me the circuit diagram

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…

Hi how can i measure height using push button?
ex.
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

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.

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

why i have error when compiling this coding? anyone can help

How I can make circuit in Proteus ?

Leave a comment