Skip to content
BeginnerUnoarduino-unohc-sr04ultrasonic

Ultrasonic Parking Sensor with Arduino Uno

Wire an HC-SR04 ultrasonic module to an Arduino Uno R3 and drive a buzzer that beeps faster as obstacles get closer. Ideal first project — no libraries needed, pure digitalRead/tone logic.

SolderHub10/17/2026 14 min read 4 views

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 items
NameQtyLink
Arduino Uno R3×1Buy ↗
HC-SR04 Ultrasonic Sensor×1Buy ↗
5V Active Buzzer×1—
Red LED (3 mm or 5 mm)×1—
220 Ω Resistor×1—
Full-size Breadboard×1—
Jumper Wires (M-M)×8—
USB Type-A to B Cable×1—

Need 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 PinArduino Pin
VCC5V
TRIGD9
ECHOD10
GNDGND

Buzzer + → D8. LED anode → D7 through a 220 Ω resistor to GND.

C++

Live simulation

Steps

  1. 1Assemble the circuit on a breadboard following the wiring table above
  2. 2Open Arduino IDE 2, select board: Arduino Uno, and the correct COM port
  3. 3Paste the sketch and click Upload
  4. 4Open Serial Monitor at 9600 baud to watch live distance readings
  5. 5Move your hand toward the sensor — the buzzer pattern should change at each threshold
  6. 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

Q&A is currently disabled site-wide.

Related projects