Cirkit Designer LogoCirkit DesignerYour all-in-one circuit design IDE Launch Cirkit Designer App

Arduino-Based IR Sensor Parking System with LCD Display

View and Edit Project In Cirkit DesignerImage of Arduino-Based IR Sensor Parking System with LCD Display

Circuit Documentation

Summary

The circuit is designed to monitor and display the status of parking spaces using infrared (IR) sensors and a 16x2 LCD display. It includes an Arduino UNO microcontroller to process signals from the IR sensors and control the output to the LCD and LEDs. The circuit uses four IR sensors to detect the presence of cars in parking spaces and the entry/exit of cars. Two LEDs (red and green) indicate the occupancy status of the parking spaces. The 16x2 LCD displays the number of available parking spaces. The circuit is powered by the 5V output from the Arduino UNO.

Component List

Wiring Details

IR Sensors

LEDs

Resistors (220 Ohms)

Arduino UNO

16x2 LCD

Documented Code

#include <LiquidCrystal.h>

// Initialize the LCD (RS, E, D4, D5, D6, D7)
LiquidCrystal lcd(7, 8, 9, 10, 11, 12);

// IR sensor pins
const int entryIR = 2;       // Entry sensor
const int exitIR = 3;        // Exit sensor
const int occupancyIR1 = 4;  // Occupancy sensor for space 1
const int occupancyIR2 = 5;  // Occupancy sensor for space 2
const int greenLED = 6;      // Green LED for available
const int redLED = 13;       // Red LED for occupied

// Parking space counter
int parkingSpaces = 0; // Track number of parked cars
const int totalSpaces = 2; // Total parking spaces

void setup() {
  lcd.begin(16, 2);
  pinMode(entryIR, INPUT);
  pinMode(exitIR, INPUT);
  pinMode(occupancyIR1, INPUT);
  pinMode(occupancyIR2, INPUT);
  pinMode(greenLED, OUTPUT);
  pinMode(redLED, OUTPUT);
  
  lcd.print("Parking System");
  delay(2000);
}

void loop() {
  // Read the entry and exit IR sensors
  int entryStatus = digitalRead(entryIR);
  int exitStatus = digitalRead(exitIR);
  
  // Check if a car has entered
  if (entryStatus == LOW) { // Assuming LOW means a car has entered
    if (parkingSpaces < totalSpaces) {
      parkingSpaces++;
      delay(1000); // Debounce delay
    }
  }

  // Check if a car has exited
  if (exitStatus == LOW) { // Assuming LOW means a car has exited
    if (parkingSpaces > 0) {
      parkingSpaces--;
      delay(1000); // Debounce delay
    }
  }

  // Check occupancy sensors
  int occupied1 = digitalRead(occupancyIR1);
  int occupied2 = digitalRead(occupancyIR2);

  // Update LEDs based on occupancy
  if (occupied1 == LOW || occupied2 == LOW) {
    digitalWrite(redLED, HIGH);  // If any space is occupied, turn on the red LED
    digitalWrite(greenLED, LOW);  // Turn off the green LED
  } else {
    digitalWrite(redLED, LOW);    // No space occupied
    digitalWrite(greenLED, HIGH); // Turn on the green LED
  }

  // Update the LCD display
  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Parking Spaces:");
  lcd.setCursor(0, 1);
  lcd.print(parkingSpaces);
  
  delay(500); // Refresh rate for the LCD display
}

This code is designed to run on an Arduino UNO and uses the LiquidCrystal library to interface with a 16x2 LCD. It reads inputs from IR sensors to determine the occupancy of parking spaces and updates the LCD and LEDs accordingly.