Visual and audible proximity warning system for vehicle parking assistance
HC-SR04 TRIG → GPIO23 (Pin 16) | ECHO → GPIO24 (Pin 18)
Green LED → GPIO17 (Pin 11) | Yellow LED → GPIO27 (Pin 13) | Red LED → GPIO22 (Pin 15)
Each LED needs a 220Ω resistor to Ground. HC-SR04 VCC → 5V, GND → Ground
An intelligent parking assistance system using ultrasonic distance measurement and visual feedback. The system measures the distance to obstacles in real-time and provides graduated visual warnings through a series of LEDs that change color based on proximity.
This project demonstrates practical embedded systems development, combining sensor interfacing with real-time control logic to create a functional safety system suitable for garage installations or warehouse vehicle operations.
This project works with any Raspberry Pi model that has GPIO pins:
Note: All models use the same 40-pin GPIO header layout, so the pin connections remain consistent across versions.
| Component | Component Pin | GPIO Pin | Physical Pin Number |
|---|---|---|---|
| HC-SR04 | VCC | 5V Power | Pin 2 or Pin 4 |
| HC-SR04 | TRIG | GPIO23 | Pin 16 |
| HC-SR04 | ECHO | GPIO24 | Pin 18 |
| HC-SR04 | GND | Ground | Pin 6, 9, 14, 20, 25, 30, 34, or 39 |
| Green LED | Anode (+) | GPIO17 | Pin 11 |
| Yellow LED | Anode (+) | GPIO27 | Pin 13 |
| Red LED | Anode (+) | GPIO22 | Pin 15 |
| All LEDs | Cathode (-) | Ground (via 220Ω resistor) | Any Ground pin |
Important: Each LED must have a 220Ω current-limiting resistor between the LED cathode and Ground. The GPIO pins are shown in BCM numbering format (used in the code).
Important: Each LED must have a 220Ω current-limiting resistor between the LED cathode and Ground. The GPIO pins are shown in BCM numbering format (used in the code).
Quick Summary: HC-SR04 connects to GPIO23 & GPIO24. LEDs connect to GPIO17 (Green), GPIO27 (Yellow), and GPIO22 (Red).
Core distance measurement and LED control logic:
Installation: No additional libraries required - uses built-in RPi.GPIO
Make executable with: chmod +x ultrasonic-parking-assistant.py
| Distance Range | Status | LED Indicator | Action |
|---|---|---|---|
| > 50 cm | Safe | Green LED | Continue approach |
| 20-50 cm | Caution | Yellow LED | Slow down |
| < 20 cm | Danger | Red LED (+ Buzzer) | Stop immediately |
Beyond parking assistance, this system can be adapted for various applications including warehouse automation for forklift safety, robotic obstacle avoidance, liquid level monitoring in tanks, automated door systems, security perimeter detection, and industrial material handling operations.