How to make a smart Parking with Arduino and shift register

 

Project Description

This Arduino project with code is a smart parking status display system designed to monitor and show the availability of parking spots in real-time. It leverages a 74HC165 shift register to read the statuses of multiple parking spots using minimal Arduino pins and displays the results on a 16x2 LCD screen.


Key Features

  1. Real-Time Parking Spot Monitoring:

    • The system can monitor up to 8 parking spots using switches, sensors, or buttons connected to the 74HC165 shift register.
    • Each spot’s availability is represented as either:
      • X: Occupied.
      • Y: Available.
  2. Efficient Pin Usage:

    • The 74HC165 shift register reads the states of 8 parking spots using only 3 Arduino pins for control and communication:
      • SH/LD: Shift/Load Control.
      • CLK: Clock Signal.
      • SO: Serial Output.
  3. Visual Feedback:

    • A 16x2 LCD displays the parking statuses:
      • Row 1: Labels the parking spots (1|2|3|4|5|6|7|8).
      • Row 2: Shows real-time statuses (X|Y|X|Y...).
  4. User-Friendly Design:

    • Compact, scalable, and easy to implement in real-world parking lots.
    • Minimal hardware requirements for efficient cost and power usage.


Schematic:

Schematic showing the connections in Proteus 8 of the 8 parking spots with the Shifter and the connections from the shifter to the Arduino UNO, and to the LCD.

Connections:

Connections of arduino UNO in Proteus 8 to the shifter and to the LCD






Code:

#include <Wire.h>
#include <LiquidCrystal.h>
#include <SPI.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
byte data;

// Number of parking spots
const int NUM_SPOTS = 8;

// Parking spot statuses
bool spots[NUM_SPOTS];

void setup() {
  // LCD setup
  lcd.begin(16, 2);
  lcd.clear();


  // 74HC165 control pins
  pinMode(SH_LD, OUTPUT);
  pinMode(CLK, OUTPUT);
  pinMode(SO, INPUT);
  digitalWrite(SH_LD, LOW);   // Activate parallel load
  digitalWrite(CLK, LOW);  // Pulse the clock to shift data


  Serial.begin(9600);
}

void loop() {
  // Read parking spot statuses from shift register
 
   readShiftRegister(spots);
 
  // Update parking spot statuses
  //for (int i = 0; i < NUM_SPOTS; i++) {
   // spots[i] = (readShiftRegister() >> i)*0x01; // Extract each bit
   
  // Display statuses on LCD
  lcd.clear();

  // Display first 4 spots on the first row
  lcd.setCursor(0, 0); // Divide row into 4 blocks
  lcd.print("1|2|3|4|5|6|7|8");
  lcd.setCursor(0, 1);
  for (int i = 0; i < 8; i++) {
  // Divide row into 4 blocks
  lcd.print(spots[i] ? "X|" : "Y|");
  }
  // Display next 4 spots on the second row
  delay(500); // Refresh every 500 ms
}

// Function to read the shift register
void readShiftRegister(bool ar[8]) {
   // Reset data before reading
   

  // Load parallel data into the shift register
  digitalWrite(SH_LD, LOW);   // Activate parallel load
  delayMicroseconds(5);       // Wait for data to load
  digitalWrite(SH_LD, HIGH);  // Set to shift mode

  // Shift out the bits one by one
  for (int i = 0; i < NUM_SPOTS; i++) {
    digitalWrite(CLK, LOW);  // Pulse the clock to shift data
    delayMicroseconds(5);
    ar[i]= (digitalRead(SO) << (7 - i));
 // Read the SO pin and store the bit
    digitalWrite(CLK, HIGH);
    //Serial.print(ar[i]);
    delayMicroseconds(5);

  }
 


}

How It Works

  1. Parking Spot Detection:

    • Each parking spot is connected to a parallel input pin (D0-D7) on the 74HC165 shift register.
    • The sensors or switches indicate whether a spot is occupied (HIGH) or free (LOW).
  2. Data Processing:

    • The 74HC165 converts the parallel data from the parking spots into serialized data.
    • The serialized data is sent to the Arduino via the SO pin.
  3. Data Display:

    • The Arduino decodes the data and updates the 16x2 LCD.
    • The first row shows the spot labels, and the second row shows the availability status of each spot.
  4. System Refresh:

    • The system refreshes every 500 milliseconds, ensuring up-to-date information.

Applications

  1. Parking Management:
    • Ideal for monitoring parking lots in malls, offices, or residential complexes.
  2. Smart Cities:
    • Can be integrated into IoT systems for real-time parking availability tracking.
  3. Scalable Design:
    • Additional 74HC165 registers can be daisy-chained to monitor more parking spots.
Or just get the project from this link: 
https://drive.google.com/file/d/1fv0RsBjE6PtrPl0H1EH10LGr1X9X0lDe/view?usp=drive_link

Advantages

  1. Efficient Pin Usage:
    • Only 3 Arduino pins are required to manage 8 parking spots.
  2. Real-Time Updates:
    • Instant feedback on parking statuses displayed on the LCD.
  3. Scalability:
    • Can expand to handle more spots by adding additional shift registers.
  4. Cost-Effective:
    • Uses readily available and affordable components.
Discover how to create a smart parking lot with Arduino Uno through a range of easy Arduino Uno projects for beginners. Engage with exciting Arduino Uno projects that include code and delve into Arduino Uno Proteus 8 simulations with code to deepen your knowledge. Our extensive Arduino tutorials feature various useful Arduino projects, including Arduino UNO shift register projects and a comprehensive shift register Proteus tutorial. Each shift register project with code is crafted to enhance your understanding. Explore our Proteus 8 projects that showcase the latest Arduino projects and innovative microcontroller projects using Arduino. Whether you're searching for an Arduino final year project or looking to broaden your skills, we have the resources to help you on your learning journey!

Comments