Parking Assistant on an Arduino Uno

by definetlyanepiccreator in Circuits > Arduino

17 Views, 1 Favorites, 0 Comments

Parking Assistant on an Arduino Uno

F30EBE12-3792-43CF-B5A6-E264A74C5886.jpeg

This project is a parking assistant system designed using a breadboard with an Arduino Uno and an ultrasonic sensor. The idea here is to detect how close an object is to the system and display this on an LCD screen in centimeters to ensure a collision-free system.


Prior to developing this project, I investigated the mechanism by which existing parking sensors are implemented in cars. I also looked for existing projects similar to mine that utilize Arduino. Most existing projects employ the use of ultrasonic sensors since they are cheaper and more accurate over shorter ranges for objects behind a car. Through these projects, I gained insight into how distance is measured using the time taken for a sound wave to travel to an object and back.


Based on this research, I created my own project that aims to provide visual feedback using an LCD and LEDs, and also uses an AND gate to showcase digital logic control. This makes my project both practical and applicable to Computer Engineering principles.

Supplies

DAB24DE7-3844-4194-911A-81320EF5DFC2.jpeg
  1. Arduino Uno
  2. I2C LCD (20x4)
  3. Ultrasonic Distance Sensor
  4. Slide Switch
  5. Red LED (1x)
  6. Green LED (1x)
  7. Resistors (2x 330 Ω)
  8. Potentiometer
  9. 1x AND Gate (IC)
  10. Breadboard
  11. Jumper Wires

Understanding How the System Works

Before building, it’s important to understand the logic of the project.

  1. The distance sensor continuously measures the distance between the system and nearby objects.
  2. The Arduino processes this data and converts it into centimeters.
  3. The LCD displays the distance in real time.
  4. LEDs provide a visual warning:
  5. Green LED: Object is at a safe distance
  6. Red LED: Object is too close
  7. A slide switch allows the assistant system to be turned ON or OFF.
  8. An AND gate ensures the assistant system only activates when both the switch is ON and the Arduino is powered.

Setting Up the Breadboard Power Rails

wiringbreadboard.png
  1. Place the Arduino Uno next to the breadboard.
  2. Connect Arduino 5V to the breadboard’s positive rail.
  3. Connect Arduino GND to the breadboard’s ground rail.
  4. Make sure all components share the same ground connection.

Connecting the Distance Sensor

distacnesensoraded.png
Othersidee3.png
  1. Place the distance sensor on the breadboard.
  2. Connect:
  3. VCC → 5V rail
  4. GND → Ground rail
  5. Signal pins → Assigned Arduino digital pins
  6. Ensure the sensor is facing outward to detect approaching objects.

This sensor is responsible for measuring how close an object is to the system.

Wiring the I2C LCD Display (20x4)

LCDwiring.png
lcd+pot.png
  1. Connect the I2C LCD module to the breadboard (Note that the one on the image shown is a 16x4 LCD module, so imagine it as a 20x4).
  2. Wire the LCD:
  3. VCC → 5V
  4. GND → GND
  5. SDA → Arduino SDA pin
  6. SCL → Arduino SCL pin
  7. Use the potentiometer to adjust the LCD contrast:
  8. Middle pin → LCD contrast input
  9. Side pins → 5V and GND

The LCD will display the measured distance in centimeters.

Adding the LED Warning System

LEDSadded.png
  1. Place the red and green LEDs on the breadboard.
  2. Connect a 330 Ω resistor in series with each LED.
  3. Wire:
  4. Green LED → Arduino output pin
  5. Red LED → Arduino output pin
  6. Connect LED cathodes to ground with the resistors for efficiency.

The LEDs provide quick visual feedback for safe and unsafe distances.

Integrating the Slide Switch

andgateandslide.png
  1. Place the slide switch on the breadboard.
  2. Connect one side to 5V.
  3. Connect the other side to ground (pull-down).
  4. Connect the switch output to the AND gate input.

This switch allows the user to manually enable or disable the parking assistant.

Using the AND Gate for System Control

allandin.png
allwireout.png
  1. Place the AND gate IC on the breadboard.
  2. Connect:
  3. Input 4B → Slide switch output
  4. Input 4A → Arduino control signal
  5. Output 4 → Arduino pin 6 + AND gate input 1A and 2A
  6. Input 1B → Arduino pin 7
  7. Input 2B → Arduino pin 9
  8. Output 1 → Red LED Anode
  9. Output 2 → Green LED Anode
  10. This ensures the system only runs when both conditions are true.

This step demonstrates the use of digital logic in a real-world application.

Arduino Programming Logic

The Arduino program performs the following tasks:

  1. Reads distance data from the sensor
  2. Converts time or voltage values into centimeters
  3. Displays distance on the LCD
  4. Controls LEDs based on distance thresholds

Example logic:

  1. Distance > 50 cm → Green LED ON
  2. Distance ≤ 50 cm → Red LED ON

Full Code:

// libraries
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

// LCD address 0x3F, 20 columns, 4 rows
LiquidCrystal_I2C lcd(0x3F, 20, 4);

// pins
int trigPin = 2;
int echoPin = 3;

int andPin2 = 8;
int andReadPin = 6;
int distanceReadPin = 9;
int distanceReadPin2 = 7;
int potPin = A0;

// variables
long duration;
int distance;
int limitDistance;

void setup() {
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);

pinMode(distanceReadPin, OUTPUT);
pinMode(distanceReadPin2, OUTPUT);
pinMode(andReadPin, INPUT);
pinMode(andPin2, INPUT);

lcd.init();
lcd.backlight();

lcd.setCursor(2, 1);
lcd.print("Parking Assist");
delay(1500);
lcd.clear();
}

void loop() {
int andEnabled = digitalRead(andReadPin);
// potentiometer sets distance limit (5–50 cm)
limitDistance = map(analogRead(potPin), 0, 1023, 5, 50);

// distance sensor trigger
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH, 30000); // timeout safety
distance = duration * 0.034 / 2;

lcd.clear();

lcd.setCursor(0, 1);
lcd.print("Distance: ");
lcd.print(distance);
lcd.print(" cm");

lcd.setCursor(0, 2);
lcd.print("Limit: ");
lcd.print(limitDistance);
lcd.print(" cm");

if (distance > 0 && distance <= limitDistance) {
// when the object is in contact with the distance sensor

digitalWrite(andPin2, LOW);
digitalWrite(distanceReadPin, LOW);
digitalWrite(distanceReadPin2, HIGH);
lcd.setCursor(0, 3);
lcd.print("!!! STOP !!!");
} else {
// safe to move

digitalWrite(distanceReadPin, HIGH);
digitalWrite(distanceReadPin2, LOW);

digitalWrite(andPin2, HIGH);

lcd.setCursor(0, 3);
lcd.print("Status: SAFE");
}

if (andEnabled == HIGH) {
lcd.setCursor(0, 1);
lcd.setCursor(0, 0);
lcd.print("Assistant: ENABLED");
}
else if (andEnabled == LOW) {
// parking system off

lcd.setCursor(0, 0);
lcd.print("Assistant: DISABLED");
}

delay(100);
}

Testing the Parking Assistant

F30EBE12-3792-43CF-B5A6-E264A74C5886.jpeg
  1. Power the Arduino using USB or external power.
  2. Turn the slide switch ON.
  3. Move an object closer to the sensor.
  4. Observe:
  5. Distance changing on the LCD
  6. LEDs switching based on proximity

Adjust thresholds in code if necessary.

Final Results and Improvements

This parking assistant successfully:

  1. Measures distance in real time
  2. Displays accurate distance readings
  3. Provides visual warnings to avoid collisions

Possible Improvements

  1. Add a buzzer for audio alerts
  2. Use multiple sensors for wider coverage
  3. Enclose the circuit in a protective case
  4. Add brightness control for LEDs

Downloads

Conclusion

This project demonstrates how sensors, microcontrollers, logic gates, and user interfaces can work together to solve real-world problems. A parking assistant like this could be scaled up for real vehicles or adapted for robotics and automation applications.

This makes it a strong and practical Computer Engineering final project.