Arduino garage parking sensor
Garage parking sensor is a very useful device when your parking space is limited and gaps between back wall or garage door and your car are very small. It will prevent you from hitting the wall and will help you to stop exactly where you want.

Our garage parking sensor will use HC-SR04 ultrasonic distance sensor to measure distance from a sensor position to a car. When car approaches sensor and gets in range we will light up red, yellow or green LED depending on distance readings. When detected distance deviation is not changed during 30 seconds, we will turn all LEDs off.
Also, to make sensor setup easy and simple, we will add adjustable resistor to set optimal distance.
Algorithm is very simple:
- Read value of the variable resistor and translate it into centimeters
- Check deviation and read distance from the ultrasonic sensor
- Check is current distance in a range and turn on corresponding led when needed
- Update timer and turn all LEDs off when 30 seconds passes
- Repeat
Objectives
- Learn how HC-SR04 sensor works
- Learn how to turn on and off LEDs
- Learn how to get readings from potentiometer
Parts
- Arduino UNO or compatible board
- HS-SR04 ultrasonic sensor
- 1 - 10 KOhm potentiometer
- 3 x 220 ohm resistors
- Red, yellow & green leds
- Breadboard
- Jumper wires
Wiring Diagram

Source Code
Following scatch uses NewPing v1.5 library.