AUTOMATIC PARKING SYSTEM USING ARDUINO UNO WITH FREE DOWNLOAD PROJECT

Smart Parking System Using Arduino UNO – HC-SR04 + Servo + LCD | MakeMindz
🚗 Smart City Automation Project

Smart Parking System
Using Arduino UNO

Manage 3 parking slots automatically using ultrasonic sensors, control the entry gate with a servo motor, and display live availability on a 16×2 LCD — all simulated in Tinkercad.

🔲 Arduino UNO 📡 4× HC-SR04 ⚙️ SG90 Servo 🖥️ 16×2 LCD 🅿️ 3 Parking Slots 🏙️ Smart City

This project simulates a fully functional Automatic Smart Parking System using the Arduino UNO in Tinkercad. It manages three parking slots using HC-SR04 ultrasonic sensors, controls an entry gate with a servo motor, and displays live parking availability on a 16×2 LCD display.

The system detects vehicles entering each slot in real-time and automatically opens or closes the gate based on availability. When all slots are full, the LCD displays "Parking Full" and the gate stays closed.

🧩 Components Required

🔲Arduino UNOMain controller for all logic
📡HC-SR04 ×43 for slots + 1 for entry detection
⚙️SG90 ServoEntry gate open/close mechanism
🖥️16×2 LCDDisplays slot status and messages
🔧Potentiometer10kΩ for LCD contrast control
🧪BreadboardFor prototyping all connections
🔗Jumper WiresMale-to-male connection wires
🔌USB CablePower and programming via USB

🅿️ Parking Slot Layout

3 Parking Slots + Entry Detection — Live Status Example

🚗
Slot 1 — Occupied
TRIG: D4 · ECHO: D5
Distance < threshold
Slot 2 — Free
TRIG: D6 · ECHO: D7
Distance ≥ threshold
Slot 3 — Free
TRIG: D8 · ECHO: D9
Distance ≥ threshold
🚘
Entry Sensor — HC-SR04 (TRIG: D2 · ECHO: D3)

Detects incoming vehicles at the gate. If free slots exist → servo opens gate. If full → LCD shows "Parking Full".

System Logic Flow

📡 Check All 3 Slot Sensors
🔢 Count Free Slots
🖥️ Update LCD: "Slots Available: X"
🚘 Vehicle Detected at Entry?
↓ Yes
🅿️ Any Free Slots?
✅ YES
⚙️ Open Gate (90°)
⏳ Wait → Close Gate (0°)
❌ NO
🛑 Gate Stays Closed
🖥️ LCD: "Parking Full"
🔁 Loop — Check Again

🖥️ LCD Display States

✅ Slots Available
Slots Available: 2 S1:Occ S2:Free S3:F
🚘 Vehicle Entering
Vehicle Detected! Opening Gate...
🛑 Parking Full
Parking Full! Please Wait...
🔄 All Free
Slots Available: 3 S1:F S2:F S3:F

🔌 Circuit Diagram

Arduino UNO – Smart Parking System Wiring Diagram Arduino UNO D2 (Entry TRIG) D3 (Entry ECHO) D4 (Slot1 TRIG) D5 (Slot1 ECHO) D6 (Slot2 TRIG) D7 (Slot2 ECHO) D8 (Slot3 TRIG) D9 (Slot3 ECHO) D10 (Servo PWM) D11 (LCD RS) D12 (LCD EN) D4-D7 (LCD Data) 5V GND Entry HC-SR04 TRIG→ ECHO→ Slot 1 HC-SR04 TRIG→ ECHO→ Slot 2 HC-SR04 TRIG→ ECHO→ Slot 3 HC-SR04 TRIG→ ECHO→ SG90 Servo Gate 0°=Closed 90°=Open Signal → D10 (PWM) 16×2 LCD Display Slots Available: 2 S1:Occ S2:Free S3:F RS→D11 · EN→D12 · D4-D7 → Arduino VSS→GND · VDD→5V · VO→Potentiometer Potentiometer 10kΩ — LCD Contrast Middle pin → LCD VO Power Rails 5V → All sensor VCC GND → All GND WIRE LEGEND: Entry Sensor Slot 1 Slot 2 Slot 3 Servo LCD 5V GND All HC-SR04 sensors: VCC→5V, GND→GND · LCD contrast via 10kΩ potentiometer

📋 Pin Connection Table

Sensor / DevicePinArduino PinWireNotes
Entry HC-SR04TRIGD2GreyTrigger pulse out
Entry HC-SR04ECHOD3GreyEcho return in
Slot 1 HC-SR04TRIGD4PurpleSlot 1 trigger
Slot 1 HC-SR04ECHOD5PurpleSlot 1 echo
Slot 2 HC-SR04TRIGD6OrangeSlot 2 trigger
Slot 2 HC-SR04ECHOD7OrangeSlot 2 echo
Slot 3 HC-SR04TRIGD8GreenSlot 3 trigger
Slot 3 HC-SR04ECHOD9GreenSlot 3 echo
All HC-SR04VCC5VRedAll 4 sensors powered at 5V
All HC-SR04GNDGNDBlackCommon ground
SG90 ServoSignalD10OrangePWM gate control
SG90 ServoVCC5VRedServo power
SG90 ServoGNDGNDBlackCommon ground
16×2 LCDRSD11BlueRegister select
16×2 LCDEND12BlueEnable pin
16×2 LCDD4–D7A0–A3Blue4-bit data bus
16×2 LCDVSSGNDBlackLCD ground
16×2 LCDVDD5VRedLCD power
16×2 LCDVOPot middleYellowContrast via 10kΩ potentiometer
PotentiometerPin 15VRedOne end to 5V
PotentiometerPin 3GNDBlackOther end to GND

📝 Step-by-Step Instructions

1

Install the LiquidCrystal Library

Go to Sketch → Include Library → Manage Libraries. The LiquidCrystal library (by Arduino) and Servo library are both built-in — no installation needed. Confirm they appear under Installed.

2

Wire All 4 HC-SR04 Ultrasonic Sensors

  • Entry sensor: TRIG → D2, ECHO → D3
  • Slot 1 sensor: TRIG → D4, ECHO → D5
  • Slot 2 sensor: TRIG → D6, ECHO → D7
  • Slot 3 sensor: TRIG → D8, ECHO → D9
  • All sensors: VCC → 5V, GND → GND (use breadboard power rails)
3

Wire the SG90 Servo (Gate)

  • Servo Signal (orange) → D10
  • Servo VCC (red) → 5V
  • Servo GND (brown) → GND
  • 0° = gate closed, 90° = gate open
4

Wire the 16×2 LCD Display

  • LCD RS → D11, EN → D12, D4 → A0, D5 → A1, D6 → A2, D7 → A3
  • LCD VSS → GND, VDD → 5V
  • LCD VO → middle wiper pin of the 10kΩ potentiometer
  • Potentiometer: one outer pin to 5V, other to GND
5

Set the Distance Threshold

In the code, int threshold = 10; means a slot is "Occupied" when the measured distance is less than 10 cm. Adjust this value based on your physical slot depth — typical values are 10–30 cm depending on parking space dimensions.

6

Upload and Test

  • Select Tools → Board → Arduino UNO, choose your COM port
  • Click Upload — LCD should show Slots Available: 3
  • Place an object within 10 cm of a slot sensor — it should show as Occupied
  • Simulate a vehicle at the entry sensor — gate servo should open then re-close
  • Fill all 3 slots — LCD should show Parking Full!
7

Adjust LCD Contrast

Turn the potentiometer knob slowly until text on the LCD is clearly visible. Too far one way = blank screen; too far the other = black blocks. Find the sweet spot for crisp readable characters.

💡
Tinkercad Simulation Tip

In Tinkercad, use the distance slider on each HC-SR04 component to simulate a vehicle being present or absent. Set the entry sensor below threshold to trigger the gate. Use the "Start Simulation" button to watch the LCD and servo respond in real time.

💻 Arduino Code

ARDUINO C++  ·  SmartParking.ino
/*
 * Smart Parking System Using Arduino UNO
 * 4x HC-SR04 Ultrasonic Sensors + SG90 Servo + 16x2 LCD
 *
 * Sensors:
 *   Entry: TRIG=D2, ECHO=D3
 *   Slot1: TRIG=D4, ECHO=D5
 *   Slot2: TRIG=D6, ECHO=D7
 *   Slot3: TRIG=D8, ECHO=D9
 * Servo Gate: D10
 * LCD: RS=D11, EN=D12, D4=A0, D5=A1, D6=A2, D7=A3
 *
 * Tutorial: https://www.makemindz.com
 */

#include <LiquidCrystal.h>
#include <Servo.h>

// LCD pins: RS, EN, D4, D5, D6, D7
LiquidCrystal lcd(11, 12, A0, A1, A2, A3);

Servo gateServo;

// Ultrasonic sensor pin pairs [TRIG, ECHO]
const int entryTrig = 2,  entryEcho = 3;
const int slot1Trig = 4,  slot1Echo = 5;
const int slot2Trig = 6,  slot2Echo = 7;
const int slot3Trig = 8,  slot3Echo = 9;
const int servoPin  = 10;

// Slot occupied if distance (cm) is less than this
const int threshold = 10;

bool slot1Occ, slot2Occ, slot3Occ;
int  freeSlots;

void setup() {
  lcd.begin(16, 2);
  lcd.print(" Smart Parking ");
  lcd.setCursor(0, 1);
  lcd.print("  System v1.0  ");
  delay(2000);

  gateServo.attach(servoPin);
  gateServo.write(0);  // Gate starts closed

  // Setup all sensor pins
  int trigPins[] = {entryTrig, slot1Trig, slot2Trig, slot3Trig};
  int echoPins[] = {entryEcho, slot1Echo, slot2Echo, slot3Echo};
  for (int i = 0; i < 4; i++) {
    pinMode(trigPins[i], OUTPUT);
    pinMode(echoPins[i], INPUT);
  }
}

// Measure distance using HC-SR04
long getDistance(int trigPin, int echoPin) {
  digitalWrite(trigPin, LOW);
  delayMicroseconds(2);
  digitalWrite(trigPin, HIGH);
  delayMicroseconds(10);
  digitalWrite(trigPin, LOW);
  return pulseIn(echoPin, HIGH) / 58;  // Returns cm
}

void checkSlots() {
  slot1Occ = (getDistance(slot1Trig, slot1Echo) < threshold);
  slot2Occ = (getDistance(slot2Trig, slot2Echo) < threshold);
  slot3Occ = (getDistance(slot3Trig, slot3Echo) < threshold);
  freeSlots = (int)!slot1Occ + (int)!slot2Occ + (int)!slot3Occ;
}

void updateLCD() {
  lcd.clear();
  lcd.setCursor(0, 0);
  if (freeSlots == 0) {
    lcd.print("Parking Full!   ");
  } else {
    lcd.print("Slots Avail: ");
    lcd.print(freeSlots);
  }
  lcd.setCursor(0, 1);
  lcd.print("S1:"); lcd.print(slot1Occ ? "Occ" : "F  ");
  lcd.print(" S2:"); lcd.print(slot2Occ ? "Occ" : "F");
}

void handleEntry() {
  long entryDist = getDistance(entryTrig, entryEcho);
  if (entryDist < threshold) {
    // Vehicle detected at entry
    if (freeSlots > 0) {
      // Open gate
      lcd.clear();
      lcd.setCursor(0, 0);
      lcd.print("Vehicle Detected");
      lcd.setCursor(0, 1);
      lcd.print("Opening Gate...");
      gateServo.write(90);   // Open gate
      delay(3000);          // Wait for vehicle to pass
      gateServo.write(0);    // Close gate
      lcd.clear();
      lcd.print("Gate Closed.    ");
      delay(1000);
    } else {
      // Parking is full — gate stays closed
      lcd.clear();
      lcd.print("Parking Full!   ");
      lcd.setCursor(0, 1);
      lcd.print("Please Wait...  ");
      delay(2000);
    }
  }
}

void loop() {
  checkSlots();    // Read all 3 slot sensors
  updateLCD();    // Show slot status on LCD
  handleEntry(); // Check entry sensor and control gate
  delay(500);     // Poll every 500ms
}

📐 diagram.json (Wokwi Simulation)

ℹ️
Using diagram.json in Wokwi

Go to wokwi.com → New Project → Arduino UNO. Replace the default diagram.json with the content below, paste the sketch above, and click ▶ Run to simulate. Use the HC-SR04 distance slider to simulate vehicles.

diagram.json  ·  Wokwi Smart Parking Circuit
{
  "version": 1,
  "author": "MakeMindz",
  "editor": "wokwi",
  "parts": [
    { "type": "wokwi-arduino-uno",   "id": "uno",    "top": 80,   "left": 180,  "attrs": {} },
    { "type": "wokwi-hc-sr04",      "id": "entry", "top": -80,  "left": -200, "attrs": { "label": "Entry" } },
    { "type": "wokwi-hc-sr04",      "id": "slot1", "top": 20,   "left": -200, "attrs": { "label": "Slot 1" } },
    { "type": "wokwi-hc-sr04",      "id": "slot2", "top": 120,  "left": -200, "attrs": { "label": "Slot 2" } },
    { "type": "wokwi-hc-sr04",      "id": "slot3", "top": 220,  "left": -200, "attrs": { "label": "Slot 3" } },
    { "type": "wokwi-servo",        "id": "gate",  "top": -80,  "left": 480,  "attrs": {} },
    { "type": "wokwi-lcd1602",      "id": "lcd",   "top": 80,   "left": 480,  "attrs": {} },
    { "type": "wokwi-potentiometer", "id": "pot",   "top": 260,  "left": 480,  "attrs": { "value": "10000" } }
  ],
  "connections": [
    [ "entry:TRIG", "uno:2",    "gray",   ["h0"] ],
    [ "entry:ECHO", "uno:3",    "gray",   ["h0"] ],
    [ "entry:VCC",  "uno:5V",   "red",    ["h0"] ],
    [ "entry:GND",  "uno:GND.1","black",  ["h0"] ],
    [ "slot1:TRIG", "uno:4",    "purple", ["h0"] ],
    [ "slot1:ECHO", "uno:5",    "purple", ["h0"] ],
    [ "slot1:VCC",  "uno:5V",   "red",    ["h0"] ],
    [ "slot1:GND",  "uno:GND.2","black",  ["h0"] ],
    [ "slot2:TRIG", "uno:6",    "orange", ["h0"] ],
    [ "slot2:ECHO", "uno:7",    "orange", ["h0"] ],
    [ "slot2:VCC",  "uno:5V",   "red",    ["h0"] ],
    [ "slot2:GND",  "uno:GND.3","black",  ["h0"] ],
    [ "slot3:TRIG", "uno:8",    "green",  ["h0"] ],
    [ "slot3:ECHO", "uno:9",    "green",  ["h0"] ],
    [ "slot3:VCC",  "uno:5V",   "red",    ["h0"] ],
    [ "slot3:GND",  "uno:GND.4","black",  ["h0"] ],
    [ "gate:PWM",   "uno:10",   "yellow", ["h0"] ],
    [ "gate:V+",    "uno:5V",   "red",    ["h0"] ],
    [ "gate:GND",   "uno:GND.5","black",  ["h0"] ],
    [ "lcd:RS",     "uno:11",   "blue",   ["h0"] ],
    [ "lcd:EN",     "uno:12",   "blue",   ["h0"] ],
    [ "lcd:D4",     "uno:A0",   "blue",   ["h0"] ],
    [ "lcd:D5",     "uno:A1",   "blue",   ["h0"] ],
    [ "lcd:D6",     "uno:A2",   "blue",   ["h0"] ],
    [ "lcd:D7",     "uno:A3",   "blue",   ["h0"] ],
    [ "lcd:VSS",    "uno:GND.6","black",  ["h0"] ],
    [ "lcd:VDD",    "uno:5V",   "red",    ["h0"] ],
    [ "lcd:VO",     "pot:SIG",  "yellow", ["h0"] ],
    [ "pot:VCC",    "uno:5V",   "red",    ["h0"] ],
    [ "pot:GND",    "uno:GND.7","black",  ["h0"] ]
  ],
  "dependencies": {}
}

🚀 Try the Live Simulations

Test the full parking system in your browser — adjust sensor distances and watch the servo gate and LCD respond in real time!

🎓 What Students Learn

📡
Multi-Sensor Integration

Managing 4 ultrasonic sensors simultaneously on a single Arduino

⚙️
Servo Motor Control

PWM-based gate open/close automation with position control

🖥️
LCD Interfacing

Real-time display of dynamic sensor data in 4-bit mode

🧠
Automation Logic

Conditional gate control based on sensor readings and slot count

📊
Real-Time Monitoring

Polling multiple sensors every 500ms for live status updates

💻
Embedded Programming

Functions, arrays, conditionals, and hardware abstraction in C++

🏙️ Applications

🛒 Shopping Mall Parking 🏙️ Smart City Infrastructure 🏢 Apartment Parking 🏗️ Office Parking Management 🌐 IoT Smart Parking Systems ✈️ Airport Parking 🎓 STEM Demonstrations 🔬 Science Exhibition

🚀 Possible Upgrades

🌐 IoT Remote Monitoring
📱 Mobile App Parking Status
📷 Camera Vehicle Detection
🔖 RFID Entry System
💳 Automated Billing System
☁️ Cloud Data Logging
🔔 Buzzer for Full Alert
🔢 More Parking Slots

© 2026 MakeMindz · Smart Parking System – Arduino UNO Tutorial · All rights reserved

Comments

try for free