

#define RECEIVER_PIN 2 // define the IR receiver pin of the ping to the reception of its echo off of an object. duration is the time (in microseconds) from the sending Read the signal from the sensor: a HIGH pulse whose Give a short LOW pulse beforehand to ensure a clean HIGH pulse: The sensor is triggered by a HIGH pulse of 10 or more microseconds.
_Q6T4E7piBR.png)
Test distance = (high level time×velocity of sound (340M/S) / 2, Wire connecting direct as following:Ĭonnecting Ultrasonic Sensor an the Arduino:īelow you can find the code you need for this project. (3) IF the signal back, through high level, time of high output IO duration is the time from sending ultrasonic to returning. The basic principle of work: (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. The modules includes ultrasonic transmitters, receiver and control circuit. Ultrasonic ranging module HC - SR04 provides 2cm - 400cm non-contact measurement function, the ranging accuracy can reach to 3mm. Ultrasonic sensor can detect movement of targets and measure the distance to them in many automated factories and process plants.

