1 HC-SR04: a cheap ultrasonic sensor
HC-SR04 is a commonly used ultrasonic sensor which is capable to detect obstacles in a range of 2-300cm. The sensor looks like a small PCB having two metal cylinders on the front-side and a small circuit on the back-side (see Fig.1).
In this article we will provide a simple demo to use HC-SR04. This requires a preliminary read of the sensor user manual:
HC-SR04 User Manual
1.3 Pinmap description
The sensor has 4 PIN:
- VCC, which must be connected to 5V;
- Trig, which is an input PIN to trigger the measurement;
- Echo, which is an output PIN which sent out a square wave;
- GND, which must be connected to ground.
Note that user manual specifies which GND must be connected first since a floating 5V could permanently damage the sensor.
2 How it works
The two cylinders are actually an ultrasonic receiver (R) and an ultrasonic transmitter (T) which are driven by the circuitry. The working principle is quite simple: when triggered the transmitter shoots some pulses. When sound encounters an obstacle it is echoed back and detected by the receiver. continue reading…