Problem
Backing into a tight spot with poor visibility is guesswork. The goal was a self-contained parking aid that gives clear visual and audio feedback as an obstacle gets closer, built as a complete embedded system for my Embedded Microcontrollers course.
Approach
- An HC-SR04 ultrasonic sensor measures distance, with its echo pulse timed by a hardware timer (TIM2 input capture) instead of a busy-wait loop.
- A potentiometer read through the ADC sets the “stop” distance anywhere from 20 to 150 cm, live. One button handles two actions: short press to mute, long press to turn the system on or off (interrupt-driven).
- Feedback comes from an RGB LED for distance bands, a PWM-driven buzzer, and a 16×2 LCD over I2C.
- The circuit was designed in KiCad and hand-soldered onto a protoboard shield for the Nucleo board.
How it came together
This project only worked once the electrical design and the firmware were shaped around each other:
- The sensor and LCD underperformed on the 3.3 V rail. I moved them to 5 V and kept the signals on the STM32’s 5 V-tolerant pins, so the hardware change didn’t require any level shifting.
- Raw ultrasonic readings jump around, which made the LED and LCD flicker at the edges of each distance band. A median-of-3 filter plus hysteresis in firmware fixed what looked like a hardware problem.
- The buzzer PWM and LCD updates run as small state machines rather than delays, so the sensor keeps being read on time no matter what the display is doing.
Key decisions
- Timer input capture for distance. Measuring the echo in hardware keeps timing accurate and frees the CPU.
- Filtering in software, not hardware. A median filter and hysteresis handled the noise without adding parts to the board.
- Out-of-range handling. Beyond about 60 cm the system goes quiet instead of reporting “ghost” distances or running the display for nothing.
What went wrong
Late in assembly, the buzzer stopped working. I isolated the buzzer circuit and ran continuity tests until I found the cause: a cold solder joint on the shared ground. Reflowing it fixed the problem. The 3.3 V rail issue above was also found in early power-on testing.
What I’d do differently
This is about as complete as a functional prototype gets, but it has only ever run on a desk, powered from a laptop. The idea is a retrofit that mounts on the front or rear of a vehicle with poor visibility, and getting there would mean rethinking a few things:
- A printed circuit board and an enclosure. The protoboard did its job, but a compact PCB would shrink the electronics enough to package them. Packaging is the bigger open question: the unit isn’t designed for weather, and a mount that adapts to many different vehicles is a hard design problem on its own.
- A more robust sensor. The HC-SR04 is cheap and easy to use, but its useful range is short (the system goes quiet past about 60 cm) and soft, angled, or uneven surfaces scatter its echo. I’d compare it against sensors built for vehicles, such as automotive ultrasonic or short-range radar.
- Getting the warning to the driver. The buzzer and LED are deliberate: a driver backing up is already looking in every direction and shouldn’t have to read another screen, so sound and a light in peripheral vision fit the job (the LCD is mainly useful on the bench). But the sensor sits on the bumper and the driver sits inside, so a real install needs a way to carry those signals into the cabin, by wire or wirelessly, which this version doesn’t plan for.
- Vehicle power and real testing. It would need to run from the vehicle’s power with proper regulation and protection, and be tested outdoors on actual vehicles instead of a bedroom desk.

