Ultrasonic Sensor
An ultrasonic sensor sends a short sound pulse above human hearing range. The pulse reflects from an object and returns as an echo. The controller measures the time delay and converts it into distance.
Working Principle
An ultrasonic sensor sends a short sound pulse above human hearing range. The pulse reflects from an object and returns as an echo. The controller measures the time delay and converts it into distance.
Step by Step
- Trigger pin sends a short pulse.
- The transmitter creates an ultrasonic sound wave.
- The wave reflects from an object.
- Echo pin reports how long the sound took to return.
- Distance is calculated from time and speed of sound.
Working Simulation
Verified Learning Notes
HC-SR04 sends ultrasonic sound near 40 kHz. Arduino sends a 10 microsecond trigger pulse and measures the echo pulse time.
Good for front obstacle distance. It is not a camera and cannot identify object color, shape, or material.
VCC is 5V, GND is common ground, TRIG is an Arduino output, and ECHO is an Arduino timing input on the Nano.
Measure the same object at 10 cm, 20 cm, and 30 cm. The echo time should increase almost linearly.
Simulation Challenge
Use the working simulation above before touching wires. Change one value or command at a time, predict the result, then compare it with the diagram and the real module.
- Say what input changed.
- Predict the output.
- Run the simulator.
- Explain why the result is correct for Ultrasonic Sensor.
Authenticity Checklist
- Does the diagram match Arduino Nano pin names?
- Does every signal have a common ground reference?
- Is the module powered at its correct voltage?
- Does the explanation separate signal, data, power, and mechanical motion?
Pin Details and Wiring
| HC-SR04 Pin | Connect To | Purpose |
|---|---|---|
| VCC | Arduino Nano 5V | Powers the ultrasonic module. |
| TRIG | Nano D4 | Controller sends a 10 microsecond start pulse. |
| ECHO | Nano D7 | Sensor returns a HIGH pulse; pulse width represents travel time. |
| GND | Nano GND and battery/module common GND | Shared reference for all signals. |
Speed of Sound and Propagation
At about 20 degrees C, sound travels near 343 m/s, which is 0.0343 cm per microsecond. The sensor measures round-trip travel, so the controller divides by 2 to get one-way distance.
Propagation means the wave spreads outward through air, reflects from a surface, and returns. Hard flat objects reflect strongly; soft cloth, angled surfaces, and small objects can reflect weakly or away from the receiver.
Drawbacks and Safe Use
Very close objects can be unreliable. Keep a practical minimum distance of about 2 to 4 cm.
Slanted surfaces may bounce sound away, so the echo may not return to the receiver.
Foam, cloth, hair, and curtains absorb sound and reduce echo strength.
Two ultrasonic sensors firing together can hear each other. Trigger them one at a time.
Sound speed changes with air temperature, so precision measurements need calibration.
The sensor gives distance in one direction. It does not identify object shape or color.