- Get link
- X
- Other Apps
- Get link
- X
- Other Apps
Smart Parking Management System Using Arduino and 74HC165 Shift Register
As urban areas grow and parking spaces become increasingly limited, efficient parking management systems have become essential. This project demonstrates a Smart Parking Management System that monitors the status of 8 parking spots, controls entry and exit gates using servo motors, and provides real-time feedback via an LCD and LEDs. By leveraging a 74HC165 shift register, the system efficiently manages multiple parking spots while minimizing the number of Arduino pins required.
Project Overview
The Smart Parking Management System integrates the following features:
Parking Spot Monitoring:
- Monitors up to 8 parking spots using sensors.
- Displays parking statuses (
X
for occupied,Y
for free) on a 16x2 LCD screen.
Gate Control:
- Opens the entry gate when a car is detected at the entry sensor and a parking spot is available.
- Opens the exit gate when a car is detected at the exit sensor.
LED Feedback:
- A green LED lights up when the entry gate opens.
- A red LED lights up when the parking lot is full, indicating no entry is allowed.
Shift Register Integration:
- The 74HC165 shift register efficiently reads the states of the 8 parking spots using just 3 Arduino pins.
System Workflow
Parking Spot Monitoring:
- Each parking spot is equipped with a sensor connected to the shift register.
- The shift register converts the parallel sensor inputs into serialized data, which is sent to the Arduino.
- The Arduino processes this data to determine which spots are occupied or free.
Entry Control:
- When a car is detected at the entry IR sensor:
- If a spot is available, the green LED turns on, and the entry gate opens.
- If all spots are full, the red LED lights up, and the gate remains closed.
- When a car is detected at the entry IR sensor:
Exit Control:
- When a car is detected at the exit IR sensor, the exit gate opens to allow the car to leave.
Real-Time Feedback:
- The 16x2 LCD displays:
- Row 1: Labels for the 8 parking spots (
1|2|3|4|5|6|7|8
). - Row 2: Current statuses of the spots (
X|Y|X|Y|...
).
- Row 1: Labels for the 8 parking spots (
- LEDs provide additional visual feedback for gate operations.
- The 16x2 LCD displays:
Hardware Requirements
Component | Quantity | Description |
---|---|---|
Arduino Uno | 1 | Main microcontroller board |
16x2 LCD Display | 1 | Displays parking status |
74HC165 Shift Register | 1 | Reads parking spot statuses |
IR Sensors | 2 | Detects car entry and exit |
Servo Motors | 2 | Controls entry and exit gates |
Green LED | 1 | Indicates gate is opening |
Red LED | 1 | Indicates parking is full |
Parking Spot Sensors | 8 | Monitors occupancy of each parking spot |
Resistors | 8 | Pull-down resistors for parking sensors |
Jumper Wires | As needed | For connecting components |
Breadboard | 1 | For prototyping and connections |
Hardware Connections
Shift Register (74HC165)
- SH/LD (Shift/Load): Connect to Arduino pin A1.
- CLK (Clock): Connect to Arduino pin 3.
- SO (Serial Output): Connect to Arduino pin 2.
- D0-D7 (Parallel Inputs): Connect to sensors monitoring the parking spots.
- VCC: Connect to Arduino 5V.
- GND: Connect to Arduino GND.
IR Sensors
- Entry IR Sensor:
- VCC: Connect to Arduino 5V.
- GND: Connect to Arduino GND.
- OUT: Connect to Arduino pin 4.
- Exit IR Sensor:
- VCC: Connect to Arduino 5V.
- GND: Connect to Arduino GND.
- OUT: Connect to Arduino pin 5.
Servo Motors
- Entry Gate Servo:
- Signal: Connect to Arduino pin A2.
- VCC: Connect to Arduino 5V.
- GND: Connect to Arduino GND.
- Exit Gate Servo:
- Signal: Connect to Arduino pin A3.
- VCC: Connect to Arduino 5V.
- GND: Connect to Arduino GND.
LEDs
- Green LED:
- Anode: Connect to Arduino pin 7 (with a 220Ω resistor).
- Cathode: Connect to GND.
- Red LED:
- Anode: Connect to Arduino pin 6 (with a 220Ω resistor).
- Cathode: Connect to GND.
16x2 LCD
- RS: Connect to Arduino pin 13.
- E: Connect to Arduino pin 12.
- D4-D7: Connect to Arduino pins 11, 10, 9, 8.
- VSS: Connect to GND.
- VDD: Connect to 5V.
- VO: Connect to the middle pin of a potentiometer (contrast control).
Software Functionality
Code:
#include <Wire.h>
#include <LiquidCrystal.h>
#include <Servo.h>
// LCD pins
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
// 74HC165 pins
#define SH_LD A1 // Shift/Load Bar pin
#define CLK 3 // Clock pin
#define SO 2 // Serial Output pin
#define green 7 // Green LED for gate open
#define red 6 // Red LED for parking full
// IR sensors
#define ENTRY_SENSOR 4 // Entry sensor pin
#define EXIT_SENSOR 5 // Exit sensor pin
// Servo motors
Servo entryGateServo; // Servo for entry gate (A4)
Servo exitGateServo; // Servo for exit gate (A3)
// Number of parking spots
const int NUM_SPOTS = 8; // Updated to handle 8 spots
bool spots[NUM_SPOTS]; // Parking spot statuses
int freeSpots = NUM_SPOTS; // Counter for free spots
void setup() {
// LCD setup
lcd.begin(16, 2);
lcd.clear();
// Servo setup
entryGateServo.attach(A2);
exitGateServo.attach(A3);
entryGateServo.write(0); // Keep entry gate closed
exitGateServo.write(0); // Keep exit gate closed
// 74HC165 control pins
pinMode(SH_LD, OUTPUT);
pinMode(CLK, OUTPUT);
pinMode(SO, INPUT);
pinMode(green, OUTPUT);
pinMode(red, OUTPUT);
digitalWrite(green, LOW); // Turn off green LED initially
digitalWrite(red, LOW); // Turn off red LED initially
digitalWrite(SH_LD, LOW); // Activate parallel load
digitalWrite(CLK, LOW); // Pulse the clock to shift data
// IR sensors
pinMode(ENTRY_SENSOR, INPUT);
pinMode(EXIT_SENSOR, INPUT);
Serial.begin(9600);
}
void loop() {
// Read parking spot statuses
readShiftRegister(spots);
// Calculate the number of free spots
freeSpots = 0;
for (int i = 0; i < NUM_SPOTS; i++) {
if (!spots[i]) { // If the spot is free
freeSpots++;
}
}
// Handle entry
if (digitalRead(ENTRY_SENSOR) == HIGH) {
if (freeSpots > 0) {
digitalWrite(green, HIGH); // Green LED ON
entryGateServo.write(90); // Open entry gate
delay(500); // Keep gate open for 500 ms
entryGateServo.write(0); // Close gate
digitalWrite(green, LOW); // Green LED OFF
} else {
digitalWrite(red, HIGH); // Red LED ON
delay(500); // Keep LED ON for 500 ms
digitalWrite(red, LOW); // Red LED OFF
}
}
// Handle exit
if (digitalRead(EXIT_SENSOR) == HIGH) {
exitGateServo.write(90); // Open exit gate
delay(500); // Keep gate open for 500 ms
exitGateServo.write(0); // Close gate
}
// Update the LCD
lcd.clear();
lcd.setCursor(0, 0);
lcd.print("1|2|3|4|5|6|7|8|"); // Labels for spots
lcd.setCursor(0, 1);
for (int i = 0; i < NUM_SPOTS; i++) {
lcd.print(spots[i] ? "X|" : "Y|"); // Display spot statuses
}
delay(500); // Refresh every 500 ms
}
// Function to read the shift register
void readShiftRegister(bool ar[NUM_SPOTS]) {
digitalWrite(SH_LD, LOW); // Activate parallel load
delayMicroseconds(5); // Wait for data to load
digitalWrite(SH_LD, HIGH); // Set to shift mode
for (int i = 0; i < NUM_SPOTS; i++) {
digitalWrite(CLK, LOW); // Pulse the clock to shift data
delayMicroseconds(5);
ar[i] = digitalRead(SO); // Read the SO pin and store the bit
digitalWrite(CLK, HIGH);
delayMicroseconds(5);
}
}
Initialization (
setup
):- Configures the pins for the LCD, servos, shift register, IR sensors, and LEDs.
- Initializes the LCD to display parking information.
Parking Spot Monitoring:
- The
readShiftRegister
function reads the state of 8 parking spot sensors via the shift register. - The statuses are stored in the
spots[]
array.
- The
Entry Gate Control:
- If a car is detected at the entry IR sensor:
- If there’s a free spot:
- The green LED turns on.
- The entry gate servo opens for 500ms and then closes.
- If all spots are full:
- The red LED turns on briefly to indicate the parking is full.
- If there’s a free spot:
- If a car is detected at the entry IR sensor:
Exit Gate Control:
- If a car is detected at the exit IR sensor, the exit gate servo opens for 500ms and then closes.
Real-Time Display:
- The LCD displays:
- Row 1: Labels for all 8 parking spots.
- Row 2: Current status of each spot (
X
for occupied,Y
for free).
- The LCD displays:
Expected Output
LCD Example Output:
When parking has free spots:
1|2|3|4|5|6|7|8| Y|X|Y|X|Y|Y|Y|X|
When parking is full:
1|2|3|4|5|6|7|8| X|X|X|X|X|X|X|X|
LED Behavior:
- Green LED: Lights up when the entry gate opens.
- Red LED: Lights up when parking is full.
Applications
- Parking Facilities:
- Ideal for managing entry and exit in parking lots.
- Smart City Projects:
- Can be integrated into IoT systems for remote parking management.
- Scalable Parking Solutions:
- Supports expansion by daisy-chaining additional shift registers for more spots.
- Get link
- X
- Other Apps
Comments
Post a Comment