0% found this document useful (0 votes)
5 views5 pages

Code

This document contains an Arduino program that implements an RFID access control system using an MFRC522 RFID reader, a servo motor, and an LCD display. It checks scanned RFID card or tag UIDs against predefined allowed UIDs, granting or denying access accordingly, while providing visual and auditory feedback. The system is set up to initialize components, read RFID data, and control a door mechanism based on the access decision.

Uploaded by

rajatmaity0809
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Code

This document contains an Arduino program that implements an RFID access control system using an MFRC522 RFID reader, a servo motor, and an LCD display. It checks scanned RFID card or tag UIDs against predefined allowed UIDs, granting or denying access accordingly, while providing visual and auditory feedback. The system is set up to initialize components, read RFID data, and control a door mechanism based on the access decision.

Uploaded by

rajatmaity0809
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

#include <SPI.

h>

#include <MFRC522.h>

#include <Servo.h>

#include <Wire.h>

#include <LiquidCrystal_I2C.h>

#define SS_PIN 10

#define RST_PIN 9

MFRC522 rfid(SS_PIN, RST_PIN);

Servo servo;

LiquidCrystal_I2C lcd(0x27, 16, 2);

int buzzer = 7;

// ----- ENTER YOUR RFID CARD UID -----

byte cardUID[] = {0xCB, 0xA3, 0x1, 0x4};

// ----- ENTER YOUR RFID TAG UID -----

byte tagUID[] = {0x81, 0xE1, 0x77, 0x00};

// ------------------------------------

bool compareUID(byte *scanned, byte *allowed) {

for (byte i = 0; i < 4; i++) {

if (scanned[i] != allowed[i]) return false;

return true;

}
void setup() {

[Link](9600);

[Link]();

rfid.PCD_Init();

[Link](6);

[Link](0);

pinMode(buzzer, OUTPUT);

[Link]();

[Link]();

[Link](0,0);

[Link](" RFID Access ");

[Link](0,1);

[Link](" System Ready ");

delay(2000);

[Link]();

void grantAccess() {

[Link]();

[Link](0,0);

[Link]("ACCESS GRANTED");

[Link]("ACCESS GRANTED");

digitalWrite(buzzer, HIGH); delay(100);

digitalWrite(buzzer, LOW);
[Link](90);

[Link](0,1);

[Link]("Door Opening...");

delay(2000);

[Link](0);

[Link]();

void denyAccess() {

[Link]();

[Link](0,0);

[Link]("ACCESS DENIED");

[Link]("ACCESS DENIED");

for (int i = 0; i < 3; i++) {

digitalWrite(buzzer, HIGH); delay(150);

digitalWrite(buzzer, LOW); delay(150);

[Link](0,1);

[Link]("Try Again...");

delay(1500);

[Link]();

void loop() {
[Link](0,0);

[Link]("Scan Card or Tag");

if (!rfid.PICC_IsNewCardPresent()) return;

if (!rfid.PICC_ReadCardSerial()) return;

[Link]();

[Link](0,0);

[Link]("Reading...");

[Link]("Scanned UID: ");

for (byte i = 0; i < [Link]; i++) {

[Link]([Link][i] < 0x10 ? "0" : "");

[Link]([Link][i], HEX);

[Link](" ");

[Link]();

byte *scanned = [Link];

if (compareUID(scanned, cardUID) || compareUID(scanned, tagUID)) {

grantAccess();

} else {

denyAccess();

rfid.PICC_HaltA();

[Link]();

You might also like