In this tutorial, you’ll learn about the ultrasonic module and find out how it works. In the end, you’ll be able to connect it to the Arduino board and use it as a motion detector to control your monitor with hand gestures.
The ultrasonic sensor is a proximity sensor. This sensor calculates the time and direction of ultrasound in the air by sending a short audio pulse at a frequency higher than the human hearing range and receiving it after reflection of the surface of the object. Using this time, the distance is measured at high resolution. The ultrasonic method is one of the best methods for measuring distance and detecting objects due to the high accuracy and speed, the lack of contact with the object, no corrosion and proper price. Most of the ultrasonic modules include a Transmitter and a receiver. The receiver and transmitter of the SRF04 and SRF05 modules are adjacent to each other and can detect objects in the range of 2 to 300 cm accurately. The SRF05 module is an improved version of SRF04. This version supports dual-mode and includes 5 pins to work with. But the SRF04 module has 4 pins and supports only one mode. Both of these modules have a common mode that is known as mode1.
In mode 1 first, you should apply a pulse for at least 10 microseconds to the trig pin. The module will automatically send 8 pulses at the frequency 40 kHz and set the Echo pin to 1. The Echo pin remains high until the module receives the reflected pulses from an object. Then we can calculate the time between sending and receiving the signal by measuring the time that the Echo pin is at a high logic level. In this mode leave the SRF05 OUT pin without connection.
Mode 2, which is only available in the SRF05 module, uses a single pin for both Trigger and Echo signals. To use this mode, connect the OUT pin to the ground and use the Trigger pin to send and receive the pulse. We can calculate the distance from the first object by measuring the signal duration, as mentioned before.