Views: 88 Author: Grace Publish Time: 2021-07-26 Origin: Site
HC-SR04 is a very popular sensor for measuring distance. It emits ultrasonic waves at a frequency of 40KHz. The ultrasonic waves travel through the air. If there are objects or obstacles in the path, it will bounce back to the module. Taking into account the propagation time and the speed of sound, you can calculate the distance.
●Typical working voltage: 5V
●Ultra-small static working current: less than 5mA
●The sensing angle (R3 resistance is higher, the higher the gain, the larger the detection angle):
R3 resistance is 392, no more than 15 degrees
R3 resistance is 472, no more than 30 degrees
●Detection distance (R3 resistance can adjust the gain, that is, adjust the detection distance):
R3 resistance is 392 2cm-450cm
R3 resistance is 472 2cm-700cm
●High precision: up to 0.3cm
●Blind zone (2cm) super close
VCC - +5 V supply
TRIG – Trigger input of sensor. Microcontroller applies 10 us trigger pulse to the HC-SR04 ultrasonic module.
ECHO–Echo output of sensor. Microcontroller reads/monitors this pin to detect the obstacle or to find the distance.
GND – Ground
Use IO to trigger ranging, giving a high level signal of at least 10us;
●The module automatically sends 8 40khz square waves to automatically detect whether there is a signal return.
●There is a signal return, through the IO output a high level, the high level duration is (4) the time from the transmission to the return of the ultrasonic wave. Test distance = (high time * sound speed (340M / S)) / 2
pulseIn(): Used to detect the pulse width of the high and low levels output by the pin.
pulseIn(pin, value, timeout);//time
Pin---The pin that needs to read the pulse
Value---The pulse type to be read, HIGH or LOW
Timeout---timeout time, in microseconds, the data type is unsigned long integer
The connections are pretty easy, you can refer to the below image with the breadboard circuit schematic.
If you see here, I believe you have understood the operation method of use ultrasonic sensor with Arduino. Let’s take action and try it yourself!