The circuit is designed to control a car parking system. It features an RFID scanner for identification, infrared sensors for parking space detection, LEDs for status indication, a buzzer for auditory feedback, an LCD display for visual feedback, and a relay for controlling an external device. The system operates by detecting available parking spaces and displaying the status on the LCD. The Arduino UNO serves as the central microcontroller unit to manage inputs and outputs, interfacing with the RFID module, sensors, LEDs, buzzer, and LCD.
/*
* Car Parking System
* This Arduino sketch controls a car parking system using an RFID scanner,
* infrared sensors, LEDs, a buzzer, and an LCD display. The system detects
* available parking spaces and displays the status on the LCD. The buzzer
* and LEDs provide visual and auditory feedback.
*/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
// Pin definitions
#define RFID_RST_PIN 9
#define RFID_SS_PIN 10
#define BUZZER_PIN 6
#define RED_LED_PIN 4
#define GREEN_LED_PIN 5
#define RELAY_PIN 7
#define IR_SENSOR_1_PIN A0
#define IR_SENSOR_2_PIN A1
#define IR_SENSOR_3_PIN A2
#define IR_SENSOR_4_PIN A3
#define SIM800L_RX_PIN 3
#define SIM800L_TX_PIN 2
// Create instances
LiquidCrystal_I2C lcd(0x27, 16, 2);
MFRC522 rfid(RFID_SS_PIN, RFID_RST_PIN);
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Initialize LCD
lcd.begin();
lcd.backlight();
// Initialize RFID
SPI.begin();
rfid.PCD_Init();
// Initialize pins
pinMode(BUZZER_PIN, OUTPUT);
pinMode(RED_LED_PIN, OUTPUT);
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(RELAY_PIN, OUTPUT);
pinMode(IR_SENSOR_1_PIN, INPUT);
pinMode(IR_SENSOR_2_PIN, INPUT);
pinMode(IR_SENSOR_3_PIN, INPUT);
pinMode(IR_SENSOR_4_PIN, INPUT);
pinMode(SIM800L_RX_PIN, INPUT);
pinMode(SIM800L_TX_PIN, OUTPUT);
// Initial states
digitalWrite(BUZZER_PIN, LOW);
digitalWrite(RED_LED_PIN, LOW);
digitalWrite(GREEN_LED_PIN, LOW);
digitalWrite(RELAY_PIN, LOW);
lcd.setCursor(0, 0);
lcd.print("Car Parking System");
delay(2000);
lcd.clear();
}
void loop() {
// Read IR sensors
bool space1 = digitalRead(IR_SENSOR_1_PIN);
bool space2 = digitalRead(IR_SENSOR_2_PIN);
bool space3 = digitalRead(IR_SENSOR_3_PIN);
bool space4 = digitalRead(IR_SENSOR_4_PIN);
// Check parking spaces
int availableSpaces = space1 + space2 + space3 + space4;
// Update LCD
lcd.setCursor(0, 0);
lcd.print("Spaces: ");
lcd.print(availableSpaces);
// Update LEDs and buzzer
if (availableSpaces > 0) {
digitalWrite(GREEN_LED_PIN, HIGH);
digitalWrite(RED_LED_PIN, LOW);
digitalWrite(BUZZER_PIN, LOW);
} else {
digitalWrite(GREEN_LED_PIN, LOW);
digitalWrite(RED_LED_PIN, HIGH);
digitalWrite(BUZZER_PIN, HIGH);
}
delay(1000);
}
This code is responsible for the operation of the car parking system. It initializes the components, reads the status of the IR sensors to determine the number of available parking spaces, and updates the LCD, LEDs, and buzzer accordingly.