kiroloskhairy
Published

Measure Your Height by Ultrasonic Sensor

A simple device that consists of Ultrasonic Sensor that will help us measure the height with more accuracy and less error.

BeginnerFull instructions provided5,221
Measure Your Height by Ultrasonic Sensor

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Ultrasonic Sensor - HC-SR04 (Generic)
Ultrasonic Sensor - HC-SR04 (Generic)
×1
Jumper wires (generic)
Jumper wires (generic)
×1
9V battery (generic)
9V battery (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Tape, Double Sided
Tape, Double Sided

Story

Read more

Schematics

fritzing circuit diagram for the device

simulation the device by proteus

Code

Measure Your Height

Arduino
int trig = 5;
int echo = 6;

float duration;
int distance;
int Length;
int door_Height =201;

void setup() 
{
  Serial.begin (9600);
  pinMode(trig, OUTPUT);
  pinMode(echo, INPUT);
}
void loop() 
{
  digitalWrite(trig, LOW);        
  delayMicroseconds(2);              
  digitalWrite(trig, HIGH);
  delayMicroseconds(10);           
  digitalWrite(trig, LOW);
  duration = pulseIn(echo, HIGH);
  distance = (duration/2) / 29.1;
  Length =  door_Height - distance;
  Serial.println("Distance: ");
  Serial.print(distance);
  Serial.println(" cm");
  Serial.println("Length: ");
  Serial.print(Length);
  Serial.println(" cm");
  delay(4000);
}

Credits

kiroloskhairy

kiroloskhairy

0 projects • 7 followers

Comments