Upgraded Sensing: The HY-SRF05
The HY-SRF05 Distance Measurement project replaces the ubiquitous HC-SR04 with its slightly more robust big brother. It offers improved range (up to 4.5 meters) and better precision, making it an ideal choice for advanced robotics.

What's Different?
Externally it looks similar, but the HY-SRF05 has 5 pins instead of 4.
- VCC, Trig, Echo, GND: Standard 4-pin mode.
- The "OUT" Pin: It can be put into a special 3-pin mode by tying the OUT pin to ground. In this mode, the Trigger and Echo signals share the exact same pin, which saves an I/O pin on your Arduino!
Measurement Logic
Just like other ultrasonic sensors, it relies on the speed of sound.
- Send a 10-microsecond high pulse on the trigger pin.
- The
pulseIn()function waits for the Echo pin to go HIGH and measures the microsecond duration. - Divide the duration by 58 to get centimeters, or 148 to get inches.
Real Applications
Use this sensor when you are building a drone altitude hold system or a maze-solving robot. The tighter beam angle and reduced noise filtering of the HY-SRF05 will significantly improve your project's performance.