What it teaches
A gentle beginner build in six lessons, for anyone who has run a first Uno sketch:
- Measure and show: how an HC-SR04 measures with a chirp and an echo (343 m/s, there and back), a beeping parking sensor and its stop line, then a stick of eight WS2812 LEDs that shows green, yellow and red zones.
- Steady and smart: averaging the last five readings and what that costs in time, riding out a missed echo, and a light that sleeps when the car is parked and wakes when it moves.
- Build it: where to mount the sensor and the lights, why a cold garage reads 4% long, telling the sketch the temperature, and the project: the finished garage stop light with a flashing "too close".
Open it at /learn/path/build-parking-assistant.
The circuits
- The first lesson uses the classroom Parking sensor: an HC-SR04 on pins
7 (TRIG) and 6 (ECHO), a buzzer on pin 9 and a red LED on pin 8, running
parking. - The rest use the Garage stop light: the same sensor pins and a stick of
eight WS2812 LEDs on pin 5, running
parklight. Its settings are constants at the top of the sketch: the zones (WATCH_MM,YELLOW_MM,STOP_MM,FLASH_MM),SAMPLES,HOLD_MISSES,SLEEP_MSandTEMP_C.
Drag the sensor's slider to move the car (in millimeters, 0 for nothing).
Safety
Power the finished light from a 5 V USB phone charger. Never wire anything into the house's mains wiring yourself.
Troubleshooting
- The light stays off: the car is more than 2 m away, or the slider is at
- Bring it inside 200 cm.
- The light flickers off for a moment: a missed echo. Set
HOLD_MISSESto 3. - The reading is a few centimeters off: check
TEMP_Cagainst the sensor's temperature. - It never sleeps:
SLEEP_MSis 0, or the car is still moving more than 3 cm between readings.