In this project, we will learn how to make a height measuring device. The height measuring device is a simple device used to measure the height of a person who stands under it. The device will be installed at a certain height and when anyone stands under the device, the height measuring device will measure the height of the person by subtracting the distance between the device and the person under it from the height at which the device is installed.

Components needed

  • Arduino Uno board
  • Jumper cables
  • 9 volts battery
  • I2C LCD
  • HC-SR04 Ultrasonic Sensor
  • Buzzer
  • Breadboard

Completed Circuit

The Code



//Include LCD library
#include <LiquidCrystal_I2C.h>
#include <HCSR04.h>


// initialize the library with the numbers of the interface pins
LiquidCrystal_I2C lcd(0x27,16,2);
UltraSonicDistanceSensor distanceSensor(A0,A1);

float distance;
float boxHeight = 185.0;
int buzzerPin= 8;



void setup() {
   Serial.begin(9600);
   lcd.init();   
   lcd.backlight();
   pinMode(buzzerPin, OUTPUT);
   printInstructions();
}

void loop() {
     distance = distanceSensor.measureDistanceCm();
     Serial.println(distance);
     delay(1000);

     /*
     lcd.clear();
     lcd.setCursor(0,0);
     lcd.print(distance);
     */

     
    
     if (distance < 65 ) {
      printHeight();
      delay(1000);
      tone(buzzerPin, 1000);
      delay(1000);
      noTone(buzzerPin);
      delay(5000);
     } else {
      printInstructions();
     }
     

}

void printInstructions() {
   lcd.clear();
   lcd.setCursor(0,0);
   lcd.print("Stand under the");
   lcd.setCursor(0,1);
   lcd.print("box!");
}

void printHeight() {
  int heightInCm = boxHeight - distance;
  int heightInInches = heightInCm/2.54;
  lcd.clear();
  lcd.setCursor(0,0);
  lcd.print("Height:");
  lcd.setCursor(8,0);
  lcd.print(heightInInches);
  lcd.setCursor(11,0);
  lcd.print("IN");
  lcd.setCursor(0,1);
  //lcd.print(distance);
}

Demo

2 thoughts on “Tutorial 17: Height Measuring Device

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s