Introduction: Arduino Parking Assistant - Park Your Car in the Correct Spot Every Time

In this project, I'll show you how to build your own parking assistant using an Arudino. This parking assistant measures the distance to your car and guides you to park it in the correct spot using an LCD display readout and an LED, which progressively changes from green to red. The red LED starts flashing if you get too close. A button on the assistant lets you set a new parking position as well.

This project was built using only components from the Elegoo Uno Project Super Starter Kit.


As mentioned, this project was built using the Elegoo Uno Project Super Starter Kit, so getting this kit will mean that you've got everything you need to build it.

If you don't have or want to buy a whole kit, you'll need the following components:

Step 1: Assemble Components Onto Breadboard

Start off by plugging your components into your breadboard. Try to separate them as much as possible, so that you've got lots of space to connect your jumpers.

There are three components which you should position in certain places to avoid additional jumpers:

  • Plug a 220ohm resistor onto a track connected to each of the positive (anode) legs of the LED. You'll only need the red and green legs, you can leave the blue leg disconnected.
  • Plug the wiper (center leg) of the pot onto the same track as V0 on the LCD. This pot will be used to adjust the contrast of the LCD.

Step 2: Connect Jumpers to Power & the Arduino

I've tried to keep this project as close to the example lessons in the Elegoo kit as possible so that it's pretty easy to use the same connection diagrams and just copy and paste parts of the code to get it working.

This project uses the following lessons:

  • Lesson 4 - RGB LED
  • Lesson 5 - Digital Inputs
  • Lesson 10 - Ultrasonic Sensor Module
  • Lesson 14 - LCD Display

Start off by connecting power to the components as shown in the first image. You need a GND and 5V supply to the ultrasonic sensor, GND to the LED, GND to the pushbutton, and then a number of GND and 5V connections to the LCD and pot.

Once this is done, you can connect the components to your Arduino's IO:

  • Pushbutton - D2
  • Ultraonic Sensor Echo - D3
  • Ultrasonic Sensor Trigger - D4
  • RGB LED Green Leg - D5
  • RGB LED Red Leg - D6
  • LCD RS - D7
  • LCD EN - D8
  • LCD D4 - D9
  • LCD D5 - D10
  • LCD D6 - D11
  • LCD D7 - D12

Step 3: Upload the Sketch/Code

Next, you'll need to upload the sketch to your Arduino.

Download the attached code and then open it in your Arduino IDE.

Plug in your Arduino and make sure that you've got the correct com port and board selected, then upload the code.

Step 4: Using the Parking Assistant

When you power the parking assistant up, it shows a brief Parking Assistant splash screen and then starts taking distance measurements to the object in front of the ultrasonic sensor, to a maximum of 80cm - this can be changed in the code to suit your parking spot/garage.

The distance is displayed on the LCD and the RGB LED will light up according to the distance to the object. If the object is at the maximum distance, the LED will be completely green and if it is at the minimum distance (the correct parking spot) then it will be completely red. The LED will change colour proportionally in between these two limits, with a yellow colour in the middle. If the object comes closer than the minimum distance, the LED will flash red. The LCD will continue to display the actual measured distance while the LED is flashing.

Trying moving your body or hand in front of the ultrasonic sensor and check that the measurements on the LCD change and that the RGB LED changes from green when you're far away to red when you're close by.

Step 5: Setting a New Parking Position

To set a new parking position, make sure that the car is parked in the new position to be set and that the display is showing the correct distance to the car, then push the button to update the parking position. Note that this doesn't change the maximum distance, so if you need to park your car further than this distance, then you'll need to update this in the code, this adjustment is meant to be used for fine adjustment.

Try placing an object or your hand at a certain distance, say around 40cm from the ultrasonic sensor and push the button. The LED should flash green and then red and the new distance will then be set. You should now notice that the RGB LED turns completely red by 40cm instead of 20cm and starts flashing when the distance is less than 40cm.

To reset the distance, set the object to 20cm from the sensor and press the button again.

The correct spot being 20cm and the maximum distance being 80cm are just arbitrary numbers used for this example. You'll need to set up your own limits for your own garage and car before you use it.

That's it, your parking assistant can now be installed into an enclosure and mounted onto the wall in your garage. You might also want to position the LCD and LED a bit further up the wall than the ultrasonic sensor so that it's easier to see.

Let me know what you would change or do differently in the comments section.