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

Arduino UNO Based Automated Parking System with IR Sensors and Servo Control

View and Edit Project In Cirkit DesignerImage of Arduino UNO Based Automated Parking System with IR Sensors and Servo Control

Circuit Documentation

Summary

The circuit in question is designed to implement an Arduino-based parking system. It utilizes an Arduino UNO as the central processing unit, interfacing with two IR sensors for vehicle detection, two servos for gate control, and an LCD screen for user interface and display. The Arduino UNO is responsible for controlling the servos based on the input from the IR sensors and updating the parking availability status on the LCD screen.

Component List

Arduino UNO

IR Sensor (2x)

LCD Screen 16x2 I2C

Servo (2x)

Wiring Details

Arduino UNO

IR Sensor

LCD Screen 16x2 I2C

Servo

Documented Code

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <Servo.h> 

LiquidCrystal_I2C lcd(0x27, 16, 2);   
Servo servoIn;
Servo servoOut;

int IRIn = 2;
int IROut = 4;
int Slot = 4;           // Total number of parking Slots
int flag1 = 0;
int flag2 = 0;

void setup() {
  Serial.begin(9600); 
  lcd.init();            // Initialize the LCD
  lcd.backlight();       // Turn on the backlight

  pinMode(IRIn, INPUT);
  pinMode(IROut, INPUT);
  
  servoIn.attach(3);
  servoOut.attach(5);
  servoIn.write(90);     // Start the servo at stop position
  servoOut.write(90);

  lcd.setCursor(0, 0);
  lcd.print("     ARDUINO    ");
  lcd.setCursor(0, 1);
  lcd.print(" PARKING SYSTEM ");
  delay(2000);
  lcd.clear();  
}

void loop() {
  if (digitalRead(IRIn) == LOW && flag1 == 0) {
    flag1 = 1;
    Slot += 1;  // Increase Slot count on IR1 detection

    servoIn.write(180);  // Open servo on pin 4
    delay(200);         // Delay to keep the servo open
    servoIn.write(90); // Close servo
    delay(2000);
    servoIn.write(0);
    delay(200);
    servoIn.write(90); // Close servo
  }

  if (digitalRead(IROut) == LOW && flag2 == 0) {
    flag2 = 1;
    
    // Only decrease slot if it's greater than 0 to prevent negative slots
    if (Slot > 0) {
      Slot -= 1;  // Decrease Slot count on IR2 detection
    }

    servoOut.write(0);  // Open servo on pin 5
    delay(200);         // Delay to keep the servo open
    servoOut.write(90); // Close servo
    delay(2000);
    servoOut.write(180);
    delay(200);
    servoOut.write(90); // Close servo
  }

  if (flag1 == 1 && digitalRead(IRIn) == HIGH) {
    flag1 = 0;
  }
  if (flag2 == 1 && digitalRead(IROut) == HIGH) {
    flag2 = 0;
  }

  if (Slot == 0) {  // Check if parking is full
    lcd.setCursor(0, 0);
    lcd.print("    SORRY :(    ");  
    lcd.setCursor(0, 1);
    lcd.print("  Parking Full  "); 
    delay(3000);
    lcd.clear();
  } else {
    lcd.setCursor(0, 0);
    lcd.print("    WELCOME!    ");
    lcd.setCursor(0, 1);
    lcd.print("Slot Left: ");
    lcd.print(Slot);
  }
}

This code is designed to run on the Arduino UNO and controls the parking system. It initializes the LCD and servos, reads the IR sensors to detect vehicle presence, and updates the parking slot count accordingly. The LCD displays the parking status, and the servos act as gates that open or close based on vehicle detection.