wirecraft

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

Mini Map
power
ground
data
signal
analog

Parts

PartRefsQtyEst.
HC-SR04 ultrasonic rangerUltrasonic1$1.90
Passive piezo buzzerBuzzer1$0.60
LED (5 mm) + 220 Ω resistorLED1$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

src/main.cpp
1// Parking Sensor
2// 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 LED
4//
5// Wiring, parts and step-by-step assembly live alongside this file.
6
7#include <Arduino.h>
8
9#define ULTRASONIC_TRIG 2
10#define ULTRASONIC_ECHO 3
11#define BUZZER_PIN 5
12#define LED_PIN 4
13
14float ultrasonicCm = 0;
15
16float 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}
23
24void 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}
32
33void loop() {
34 // --- Read sensors ---
35 ultrasonicCm = readUltrasonicCm(ULTRASONIC_TRIG, ULTRASONIC_ECHO);
36
37 // --- 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 }
50
51 delay(50);
52}
53
platformio.ini
1; PlatformIO project for Parking Sensor
2[env:uno]
3platform = atmelavr
4board = uno
5framework = arduino
6monitor_speed = 115200
7

Assembly

  1. 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. 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. 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. 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. 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. 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. 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. 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.