This circuit is designed to control access using RFID cards, solenoids, and an inductive sensor. The system includes an Arduino Mega 2560 microcontroller, RFID readers, solenoids, inductive sensors, relays, a buzzer, and an LCD display. The circuit allows authorized access through RFID cards and monitors the door status using inductive sensors. Unauthorized access triggers an alarm.
Arduino Mega 2560
RFID-RC522
Solenoid
Inductive Sensor
1-Channel Relay (5V 10A)
Buzzer
12V Power Supply
LCD I2C
5V: Connected to:
3V3: Connected to:
VIN: Connected to:
GND: Connected to:
D4 PWM: Connected to:
D5 PWM: Connected to:
D6 PWM: Connected to:
D7 PWM: Connected to:
D8 PWM: Connected to:
D9 PWM: Connected to:
D20/SDA: Connected to:
D21/SCL: Connected to:
D50: Connected to:
D51: Connected to:
D52: Connected to:
D53: Connected to:
VCC (3.3V): Connected to:
RST: Connected to:
GND: Connected to:
MISO: Connected to:
MOSI: Connected to:
SCK: Connected to:
SDA: Connected to:
pin1: Connected to:
pin2: Connected to:
Signal: Connected to:
VCC: Connected to:
GND: Connected to:
NC: Connected to:
signal: Connected to:
C: Connected to:
power: Connected to:
ground: Connected to:
PIN: Connected to:
GND: Connected to:
+: Connected to:
-: Connected to:
GND: Connected to:
VCC: Connected to:
SDA: Connected to:
SCL: Connected to:
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#include <SPI.h>
#include <MFRC522.h>
// Pin Definitions
#define RST_PIN 9
#define SS_PIN 53
#define BUZZER_PIN 8
#define SOLENOID1_PIN 7
#define SOLENOID2_PIN 6
#define PROX_SENSOR1_PIN 5
#define PROX_SENSOR2_PIN 4
// RFID Master and Teacher Cards
#define MASTER_CARD_1 "BD9DCD2C" //VALLE
#define MASTER_CARD_2 "7D61D02C" //IGNACIO
#define MASTER_CARD_3 "" //CARDENAS CDB2CF7A
#define TEACHER_CARD_1 "5B83A70D" //RFID TAG
#define TEACHER_CARD_2 "2333911B" //RFID CARD
// Initialize LCD with I2C
LiquidCrystal_I2C lcd(0x27, 16, 2);
// Initialize RFID Reader
MFRC522 mfrc522(SS_PIN, RST_PIN);
// Global variables
long countdownTime = 180 * 60; // 180 minutes in seconds
bool doorOpen = false;
void setup() {
// Initialize Serial communication
Serial.begin(9600);
// Initialize LCD
lcd.init();
lcd.backlight();
// Initialize RFID
SPI.begin();
mfrc522.PCD_Init();
// Initialize pins
pinMode(BUZZER_PIN, OUTPUT);
pinMode(SOLENOID1_PIN, OUTPUT);
pinMode(SOLENOID2_PIN, OUTPUT);
pinMode(PROX_SENSOR1_PIN, INPUT);
pinMode(PROX_SENSOR2_PIN, INPUT);
// Initial state
closeSolenoids();
updateLCD(" Tap card here ");
}
void loop() {
// Check for forced door open
if ((!digitalRead(PROX_SENSOR1_PIN) && !digitalRead(PROX_SENSOR2_PIN)) && !doorOpen) {
unauthorizedAccess();
}
// Check for RFID card presence
if (mfrc522.PICC_IsNewCardPresent() && mfrc522.PICC_ReadCardSerial()) {
String cardUID = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
cardUID += String(mfrc522.uid.uidByte[i] < 0x10 ? "0" : "");
cardUID += String(mfrc522.uid.uidByte[i], HEX);
}
cardUID.toUpperCase();
if (cardUID == MASTER_CARD_1 || MASTER_CARD_2 || MASTER_CARD_3) {
openSolenoidsUnlimited();
} else if (cardUID == TEACHER_CARD_1 || TEACHER_CARD_2) {
openSolenoidsWithTimer();
} else {
unauthorizedAccess();
}
mfrc522