Ultrasonic parking sensor
Beeps faster and turns red as something gets closer. The HC-SR04 sends eight 40 kHz pulses when TRIG gets a 10 µs pulse, then holds ECHO high until the echo returns. pulseIn() measures that time; at 343 m/s a centimetre there and back takes 58 µs. Over 60 cm: green and quiet. 20–60 cm: yellow and beeps that speed up as you get closer. Under 20 cm: red; under 10 cm the beep stays on.

Build it in the labGuided build, test sheet and fault finding, free in your browser.
Parts list
Test procedure
Each test has an expected value and a pass range, like a factory test sheet:
- Far: green, quiet
- 40 cm: yellow, beeping
- 8 cm: red, steady tone
How it works
What it does: Beeps faster and turns red as something gets closer.
Build it (guided or ready-made), then run its test procedure below. Every test has an expected value and a pass range, just like a factory test sheet.
Things to try
- Slide the distance from 100 down to 5 cm and listen to the beeps close up.
- The ECHO pin gives 5 V: fine for an Uno, too much for an ESP32 (3.3 V). There it needs a 1 kΩ / 2 kΩ divider.
- Sound speeds up 0.6 m/s per °C. At 35 °C the reading is about 1 % short: add a temperature sensor and correct it.
Background
Bats did it first; car parking sensors (1970s Toyota, then everywhere) use the same 40 kHz ultrasound.