cupboard

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.

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

 

ultrasonicultrasonic

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

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

Jpeg

How to Make your Line Following Robot Faster?

Control Mobile Robot through WiFi with ESP-WiFi Shield (Arduino + Andriod)

Arduino + 2A motor + Encoder

Arduino + 2A Motor Shield + Encoder Motor

ESPresoo Lite V2 Package

Bringing IoT to Everyone – Collaboration of ASEAN Makers

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

Leave a Reply

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