Tuesday, June 17, 2014

Arduino Uno and HC-SR04 Ultrasonic Proximity Sensor

This is an ultrasonic sensor: sends sound waves, receives echoes and calculates the time between sending and receiving. Like a bat.

Sensor is like this:

HC-SR04

Leftmost pin is 5VDC
Second pin is Trig(ger)
Third is Echo
Last one is GND

Usage is simple: Set trig high and echo will set itself high. Get the time between (microseconds) by Arduino's pulseIn() function.

Wiring Details
Connect power pins 5VDC and GND as usual.
Connect trig to 7 as output
Connect echo to 8 as input

distance = duration/58.2 (centimeters - max distance is 200)

No comments:

Post a Comment