What You'll Build
A proximity alarm that mimics the parking sensors built into modern cars. The HC-SR04 emits an ultrasonic pulse and measures the echo time to calculate distance. Your Arduino maps that distance to a buzzer tone — slow beeps at 50 cm, rapid beeps at 15 cm, and a solid tone inside 5 cm.
The whole circuit needs no libraries and uses just six wires. It's a reliable first project that teaches pulse timing, pulseIn(), and analog-to-digital mapping in about 40 lines of C++.
💡 Tip
The HC-SR04 runs on 5V and its ECHO pin outputs 5V logic. The Arduino Uno's digital pins are 5V-tolerant, so you can connect ECHO directly. On a 3.3V board (Nano 33, Pico) you'd need a voltage divider.
Components
8 itemsNeed these parts? Get this build sheet by email
Parts list with buy links, plus new builds as they're published. By subscribing you agree to our Privacy Policy. Unsubscribe anytime.
Wiring
Keep the connections simple:
| HC-SR04 Pin | Arduino Pin |
|---|---|
| VCC | 5V |
| TRIG | D9 |
| ECHO | D10 |
| GND | GND |
Buzzer + → D8. LED anode → D7 through a 220 Ω resistor to GND.
Live simulation
Steps
- 1Assemble the circuit on a breadboard following the wiring table above
- 2Open Arduino IDE 2, select board: Arduino Uno, and the correct COM port
- 3Paste the sketch and click Upload
- 4Open Serial Monitor at 9600 baud to watch live distance readings
- 5Move your hand toward the sensor — the buzzer pattern should change at each threshold
- 6Tweak WARN_CM / CLOSE_CM defines to match your use case
Going Further
- Add a 16×2 I2C LCD to display the numeric distance instead of (or alongside) the Serial Monitor
- Replace the active buzzer with a passive one and use the
tone()frequency to create a musical scale — lower pitch for far, higher for near - Mount the sensor in a 3D-printed bracket and power from a 9V battery for a portable device
- Combine two HC-SR04s (front and rear) on D9/D10 and D6/D7 for a dual-axis parking assistant