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

Arduino UNO-Based Smart Car Parking System with IR Sensors and Servo Control

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

Circuit Documentation

Summary

This circuit is designed to manage a car parking system. It uses two IR sensors to detect the presence of cars, a servo motor to control a gate, and an LCD to display the status of available parking spaces. The entire system is controlled by an Arduino UNO microcontroller.

Component List

  1. IR Sensor

    • Description: Infrared sensor used to detect the presence of a car.
    • Pins: out, gnd, vcc
  2. Servo

    • Description: Servo motor used to control the gate.
    • Pins: GND, VCC, PWM
  3. Arduino UNO

    • Description: Microcontroller used to control the entire system.
    • Pins: UNUSED, IOREF, Reset, 3.3V, 5V, GND, Vin, A0, A1, A2, A3, A4, A5, SCL, SDA, AREF, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0
  4. 16X2 LCD

    • Description: LCD display used to show the status of available parking spaces.
    • Pins: VSS, VDD, V0, RS, RW, E, D1, D0, D2, D3, D4, D6, D5, D7, A, K
  5. Resistor

    • Description: Resistor used to limit current.
    • Pins: pin1, pin2
    • Properties: Resistance: 200 Ohms

Wiring Details

IR Sensor 1

IR Sensor 2

Servo

Arduino UNO

16X2 LCD

Resistor

Code Documentation

#include <LiquidCrystal.h> // initialize the library with the numbers of the interface pins
LiquidCrystal lcd(A0, A1, A2, A3, A4, A5);
#include <Servo.h> // includes the servo library

Servo myservo1;

int ir_s1 = 2;
int ir_s2 = 4;

int Total = 5;
int Space;

int flag1 = 0;
int flag2 = 0;

void setup() {
    pinMode(ir_s1, INPUT);
    pinMode(ir_s2, INPUT);
    
    myservo1.attach(3);
    myservo1.write(100);
    
    lcd.begin(16, 2);
    lcd.setCursor(0, 0);
    lcd.print("  Car  Parking  ");
    lcd.setCursor(0, 1);
    lcd.print("     System     ");
    delay(2000);
    lcd.clear();
    
    Space = Total;
}

void loop() {
    if (digitalRead(ir_s1) == LOW && flag1 == 0) {
        if (Space > 0) {
            flag1 = 1;
            if (flag2 == 0) {
                myservo1.write(0);
                Space = Space - 1;
            }
        } else {
            lcd.setCursor(0, 0);
            lcd.print(" Sorry not Space ");
            lcd.setCursor(0, 1);
            lcd.print("    Available    ");
            delay(1000);
            lcd.clear();
        }
    }
    
    if (digitalRead(ir_s2) == LOW && flag2 == 0) {
        flag2 = 1;
        if (flag1 == 0) {
            myservo1.write(0);
            Space = Space + 1;
        }
    }
    
    if (flag1 == 1 && flag2 == 1) {
        delay(1000);
        myservo1.write(100);
        flag1 = 0;
        flag2 = 0;
    }
    
    lcd.setCursor(0, 0);
    lcd.print("Total Space: ");
    lcd.print(Total);
    
    lcd.setCursor(0, 1);
    lcd.print("Have  Space: ");
    lcd.print(Space);
}

This code initializes the LCD and servo motor, sets up the IR sensors as inputs, and continuously checks the status of the IR sensors to update the available parking spaces and control the servo motor accordingly. The LCD displays the total and available parking spaces.