HC-SR04 ultrasonic distance sensor with Arduino

by ourcircuits

9 parts

A Pro Mini times an HC-SR04's echo: the simulation shows the distance on the serial monitor five times a second. Move the distance and the next reading follows. The board sends a 10 µs pulse on Trig, and pulseIn times how long Echo stays high: 58.8 µs for each centimetre, out and back. The probes show both pulses. With nothing in range the module gives its 38 ms pulse, and the sketch prints out of range.