Devices & Components
Arduino Uno Rev3
Ultrasonic Sensor - HC-SR04 (Generic)
Jumper wires (generic)
9V battery (generic)
Hardware & Tools
Tape, Double Sided
Software & Tools
Arduino IDE
Project description
Code
Measure Your Height
arduino
1int trig = 5; 2int echo = 6; 3 4float duration; 5int distance; 6int Length; 7int door_Height =201; 8 9void setup() 10{ 11 Serial.begin (9600); 12 pinMode(trig, OUTPUT); 13 pinMode(echo, INPUT); 14} 15void loop() 16{ 17 digitalWrite(trig, LOW); 18 delayMicroseconds(2); 19 digitalWrite(trig, HIGH); 20 delayMicroseconds(10); 21 digitalWrite(trig, LOW); 22 duration = pulseIn(echo, HIGH); 23 distance = (duration/2) / 29.1; 24 Length = door_Height - distance; 25 Serial.println("Distance: "); 26 Serial.print(distance); 27 Serial.println(" cm"); 28 Serial.println("Length: "); 29 Serial.print(Length); 30 Serial.println(" cm"); 31 delay(4000); 32} 33
Measure Your Height
arduino
1int trig = 5; 2int echo = 6; 3 4float duration; 5int distance; 6int Length; 7int door_Height =201; 8 9void setup() 10{ 11 Serial.begin (9600); 12 pinMode(trig, OUTPUT); 13 pinMode(echo, INPUT); 14} 15void loop() 16{ 17 digitalWrite(trig, LOW); 18 delayMicroseconds(2); 19 digitalWrite(trig, HIGH); 20 delayMicroseconds(10); 21 digitalWrite(trig, LOW); 22 duration = pulseIn(echo, HIGH); 23 distance = (duration/2) / 29.1; 24 Length = door_Height - distance; 25 Serial.println("Distance: "); 26 Serial.print(distance); 27 Serial.println(" cm"); 28 Serial.println("Length: "); 29 Serial.print(Length); 30 Serial.println(" cm"); 31 delay(4000); 32} 33
Downloadable files
fritzing circuit diagram for the device
fritzing circuit diagram for the device

simulation the device by proteus
simulation the device by proteus
fritzing circuit diagram for the device
fritzing circuit diagram for the device

Comments
Only logged in users can leave comments