The HC-SR04 is a quick, cheap and easy way to measure distance with an Arduino or other microcontroller. It uses a pair of Ultrasonic Trancducers, one to emit a high frequency pulse of energy or sound much above the human hearing range and another to receive the reflected pulse (similar to how bats use echolocation!).
These are perfect for keeping your quadcopter a certain distance off the ground, working out if your robot is about to faceplant into your wall or how long you have until your mum is about to invade your secret laboratory!!
- 20mm - 5000mm Ultrasonic sensing distance
- 3mm positional accuracy.
- 5V Supply Input
- All processing done onboard and a single output pin returns a pulse-width proportional to object distance.
- Works by sending a 40kHz pulse and measuring the time for the pulse to be 'reflected' by an object, then using the speed of sound(~340m/s in air) the distance can be calculated.
The 4 Pins are as Follows:
- 5V Supply
- Trigger Pulse Input
- Echo Pulse Output
- 0V Ground
- Operating Voltage :5V DC
- Quiescent Current : <2mA
- Effectual Angle: <15°
- Ranging Distance : 2cm – 500 cm
- Resolution : 0.3 cm
Using this with an arduino is quick and easy, all you need to do is provide a pulse to the trigger input pin and then measure the high time of the output pin and apply the following formula:
Distance = ((Duration of high level)*(Sonic :340m/s))/2