🚀
ArkyEdu GLOSAR TIC
RO Practice Lab
Robotics & Arduino IoT Grade 8 RO Term: Senzor Ultrasonic HC-SR04 (Măsurarea Distanței cu Ultrasunete)

HC-SR04 Ultrasonic Distance Sensor

💬 Share on WhatsApp
📌 Quick Definition (Answer-First)

The HC-SR04 uses four pins (VCC, Trig, Echo, GND) to measure distance from 2 cm to 400 cm by sending a 10 µs ultrasonic pulse on Trig and timing the reflected sound wave return on Echo.

How It Works & Why It Matters

Just like bat echolocation, high-frequency 40 kHz sound waves bounce off nearby surfaces back to the sensor.

At room temperature, sound travels ~0.034 cm per microsecond; dividing duration × 0.034 by 2 converts round-trip time into one-way distance.

💻 Arduino Distance Formula (cm)
digitalWrite(trigPin, HIGH); delayMicroseconds(10);
digitalWrite(trigPin, LOW);
long duration = pulseIn(echoPin, HIGH);
float distanceCm = duration * 0.034 / 2.0;

🏫 Classroom Example

A smart trash-can lid project opens automatically with a servo motor whenever distanceCm drops below 20 cm.

⚖️ HC-SR04 Ultrasonic vs. PIR Motion Sensor

HC-SR04 gives exact distance in centimeters; PIR only outputs a digital YES/NO signal when warm motion crosses its field.

⚠️ Common Mistake in Exams & Homework

Forgetting to divide by 2 (reporting double the actual distance) or swapping VCC and GND wires.

❓ Quick Questions & Answers

Why divide duration * 0.034 by 2?
Because the measured pulse duration covers both the outgoing trip to the obstacle and the return echo back.

Related Glossary Terms

← Back to Full Glossary (A–Z)