Abdul Aziz M. Abullais

Maker

Web Designer

Graphic Designer

Drone Specialist

Photographer

Blogger

Freelancer

0

No products in the cart.

Abdul Aziz M. Abullais

Maker

Web Designer

Graphic Designer

Drone Specialist

Photographer

Blogger

Freelancer

# Height Sensor

November 6, 2017

Prior to this project, the students have already known how to work with the Ultrasonic sensor, which measures the distance from the sensor to an obstacle in front of it. in this project, we will use that to calculate the height of a person simply by standing straight under it. The mathematics behind this trick to calculate the height which is displayed on an LCD screen is shown below.

The ultrasonic sensor sends an echo and then waits for it bounce back after hitting any object, hence the distance is calculated by time is taken for the echo to come back. the speed of the echo is known which the speed of light and the time taken is divided by 2 since the echo travels two ways.

Steps:

1. First of all, the students must gather all the components shown in this diagram
2. Wiring the components together into a breadboard as shown above
3. Upload the following code to the Arduino using the Arduino interface.
```#include <LiquidCrystal.h>;

LiquidCrystal lcd(1,2,4,5,6,7);

const int trigPin=7;
const int echoPin=10;

int Led= 13;

long duration;
int distance;

void setup() {
lcd.begin (16,2);
pinMode (Led, OUTPUT);
pinMode (trigPin, OUTPUT);
pinMode (echoPin, INPUT);
Serial.begin (9600);

}

void loop() {

digitalWrite (trigPin,LOW);
delayMicroseconds (2);

digitalWrite (trigPin, HIGH);
delayMicroseconds (10);
digitalWrite (trigPin, LOW);

duration = pulseIn (echoPin, HIGH);
distance = duration/58   ;

Serial.print ("Distance: ");
Serial.print (distance);
Serial.println (" cm");
delay (120);

lcd.setCursor(0,0); // Sets the location at which subsequent text written to the LCD will be displayed
lcd.print("Distance: "); // Prints string "Distance" on the LCD
lcd.print(distance); // Prints the distance value from the sensor
lcd.print("  cm");
}
```
1. Test with a height of a known object, which can be used to calibrate the readings from the sensor.
2. Test and calibrate