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.

Arduino Theremin schematics

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


  • Learn how HC-SR04 sensor works
  • Learn how to turn on and off LEDs
  • Learn how to get readings from potentiometer


Wiring Diagram

Arduino Theremin schematics

Source Code

Following scatch uses NewPing v1.5 library.