Vehicles · Arduino Uno
Garage Parking Pal
A Arduino Uno build with 3 components. Reads: Ultrasonic. Drives: Buzzer, LED. Beep and light up when something comes within 30 cm. Mirror the alarm on the indicator LED.
3 parts · 8 connections · 8 steps
Wiring
Parts
| Part | Refs | Qty | Est. |
|---|---|---|---|
| HC-SR04 ultrasonic ranger | Ultrasonic | 1 | $1.90 |
| Passive piezo buzzer | Buzzer | 1 | $0.60 |
| LED (5 mm) + 220 Ω resistor | LED | 1 | $0.15 |
| Plus: breadboard, jumper wires, USB cable | ≈ $2.65 | ||
Prices are rough hobby-market estimates. Click a part for wiring notes and specs.
Firmware
1// Parking Sensor2// Generated by Wirecraft for the Arduino Uno (ATmega328P)3// Prompt: A parking sensor that beeps faster as the car gets too close, with a warning LED4//5// Wiring, parts and step-by-step assembly live alongside this file.67#include <Arduino.h>89#define ULTRASONIC_TRIG 210#define ULTRASONIC_ECHO 311#define BUZZER_PIN 512#define LED_PIN 41314float ultrasonicCm = 0;1516float readUltrasonicCm(int trigPin, int echoPin) {17 digitalWrite(trigPin, LOW); delayMicroseconds(2);18 digitalWrite(trigPin, HIGH); delayMicroseconds(10);19 digitalWrite(trigPin, LOW);20 long us = pulseIn(echoPin, HIGH, 30000UL);21 return us > 0 ? us / 58.0f : -1.0f;22}2324void setup() {25 Serial.begin(115200);26 pinMode(ULTRASONIC_TRIG, OUTPUT);27 pinMode(ULTRASONIC_ECHO, INPUT);28 pinMode(BUZZER_PIN, OUTPUT);29 pinMode(LED_PIN, OUTPUT);30 Serial.println(F("Parking Sensor ready."));31}3233void loop() {34 // --- Read sensors ---35 ultrasonicCm = readUltrasonicCm(ULTRASONIC_TRIG, ULTRASONIC_ECHO);3637 // --- React ---38 // Beep and light up when something comes within 30 cm.39 if (ultrasonicCm < 30) {40 tone(BUZZER_PIN, 880);41 } else {42 noTone(BUZZER_PIN);43 }44 // Mirror the alarm on the indicator LED.45 if (ultrasonicCm < 30) {46 digitalWrite(LED_PIN, HIGH);47 } else {48 digitalWrite(LED_PIN, LOW);49 }5051 delay(50);52}531; PlatformIO project for Parking Sensor2[env:uno]3platform = atmelavr4board = uno5framework = arduino6monitor_speed = 1152007Assembly
- 1
Lay out your workbench
Gather the Arduino Uno, a half-size breadboard, and a bundle of male-to-male jumper wires. Keep the parts list open — every component below gets its own spot on the breadboard. Don't plug in USB power until the last wire is placed.
- 2
Seat the board and power rails
Run a red jumper from the Arduino Uno's 3V3 (or 5V for 5 V parts) pin to the breadboard's + rail, and a black jumper from GND to the − rail. Every component's power and ground will tap these rails.
- 3
Wire the Ultrasonic
Place the HC-SR04 ultrasonic ranger on the breadboard. Power first: VCC → + rail, GND → − rail. Then signals: TRIG → D2, ECHO → D3. Tip: On 3.3 V boards, put a voltage divider (1 kΩ / 2 kΩ) on ECHO — the module echoes at 5 V.
- 4
Wire the Buzzer
Place the Passive piezo buzzer on the breadboard. Power first: GND → − rail. Then signals: SIG → D5. Tip: Passive buzzers need tone(); active ones just want HIGH. This design assumes passive.
- 5
Wire the LED
Place the LED (5 mm) + 220 Ω resistor on the breadboard. Power first: CATHODE → − rail. Then signals: ANODE → D4. Tip: The longer leg is the anode (+). The resistor can go on either leg.
- 6
Double-check before power
Trace every wire against the diagram once more — 8 connections in total. The classic mistakes: swapped power and ground, and off-by-one rows on the breadboard. Thirty seconds of checking saves a component.
- 7
Flash the firmware
Open the exported folder in VS Code with the PlatformIO extension (free), plug in the Arduino Uno over USB, and hit Upload. PlatformIO fetches the libraries listed in platformio.ini automatically. Prefer the Arduino IDE? Copy src/main.cpp into a new sketch and install the same libraries from the Library Manager.
- 8
Bring it to life
Open the Serial Monitor at 115200 baud to watch live readings. Beep and light up when something comes within 30 cm. Mirror the alarm on the indicator LED. Adjust the thresholds at the top of the sketch to match your environment.