HCSR04 is an Ultrasonic ranging module that consists of a transmitter, receiver, and control circuit. It has four pins for VCC, GND, Trigger, and Echo. You can easily interface it with microcontrollers and Arduino boards.
The basic principle of work is:
(1) Using IO trigger for at least 10us high-level signal,
(2) The Module automatically sends eight 40 kHz and detect whether there is a
pulse signal back.
(3) IF the signal back, through high level, time of high output IO duration is
the time from sending ultrasonic to returning.
Test distance = (high level time×velocity of sound (340M/S) / 2