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.
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
🅿️ Parking Slot Layout
3 Parking Slots + Entry Detection — Live Status Example
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
🖥️ LCD Display States
✅ Slots Available
🚘 Vehicle Entering
🛑 Parking Full
🔄 All Free
🔌 Circuit Diagram
📋 Pin Connection Table
| Sensor / Device | Pin | Arduino Pin | Wire | Notes |
|---|---|---|---|---|
| Entry HC-SR04 | TRIG | D2 | Grey | Trigger pulse out |
| Entry HC-SR04 | ECHO | D3 | Grey | Echo return in |
| Slot 1 HC-SR04 | TRIG | D4 | Purple | Slot 1 trigger |
| Slot 1 HC-SR04 | ECHO | D5 | Purple | Slot 1 echo |
| Slot 2 HC-SR04 | TRIG | D6 | Orange | Slot 2 trigger |
| Slot 2 HC-SR04 | ECHO | D7 | Orange | Slot 2 echo |
| Slot 3 HC-SR04 | TRIG | D8 | Green | Slot 3 trigger |
| Slot 3 HC-SR04 | ECHO | D9 | Green | Slot 3 echo |
| All HC-SR04 | VCC | 5V | Red | All 4 sensors powered at 5V |
| All HC-SR04 | GND | GND | Black | Common ground |
| SG90 Servo | Signal | D10 | Orange | PWM gate control |
| SG90 Servo | VCC | 5V | Red | Servo power |
| SG90 Servo | GND | GND | Black | Common ground |
| 16×2 LCD | RS | D11 | Blue | Register select |
| 16×2 LCD | EN | D12 | Blue | Enable pin |
| 16×2 LCD | D4–D7 | A0–A3 | Blue | 4-bit data bus |
| 16×2 LCD | VSS | GND | Black | LCD ground |
| 16×2 LCD | VDD | 5V | Red | LCD power |
| 16×2 LCD | VO | Pot middle | Yellow | Contrast via 10kΩ potentiometer |
| Potentiometer | Pin 1 | 5V | Red | One end to 5V |
| Potentiometer | Pin 3 | GND | Black | Other end to GND |
📝 Step-by-Step Instructions
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.
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)
Wire the SG90 Servo (Gate)
- Servo Signal (orange) → D10
- Servo VCC (red) → 5V
- Servo GND (brown) → GND
- 0° = gate closed, 90° = gate open
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
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.
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!
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
/* * 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.
{
"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++
Comments
Post a Comment