You are here

HC-SR04 Ultrasonic Rangefinder

HC-SR04 Ultrasonic Rangefinder (datasheet)

 


Field of View




How it Works

(from the datasheet)
A brief HIGH pulse (10uS or longer) on the Trigger pin (
Trig) triggers the ping pulse train. A short while later an echo pulse is returned on the echo pin (Echo). The distance/range to the target is proportional to the width of the echo pulse according to the equations in the image above.

Hardware Setup

 
Pin Connections
HC-SR04Arduino UNO
VCC +5V
GND GND
Trig trigPin
Echo echoPin
 
NOTE: This is a 5V device. The Arduino FIO does not have a 5V supply. If you are using an external battery pack or power supply with the FIO that does have 5V, you should be able to use this device.
 

Code

This is adapted from Examples-06.Sensors-Ping.