top of page

Build Your Own RFID Access System with Arduino (Beginner Friendly)

  • Writer: Cartell Automotive
    Cartell Automotive
  • Jun 16
  • 3 min read

Ever wanted to build a simple access control system using RFID and an Arduino? In this tutorial, I’ll walk you through a project where we scan an RFID tag, and based on whether it's authorized, light up a blue LED (Access Granted) or a red LED (Access Denied). We'll also add sound feedback and a user-friendly LCD screen.


If you are using the Starter Kit supplied by our site, Soldering would be Required..


Arduino RFID
Arduino with RFID

Difficulty: Beginner-friendly


Tools Used: Arduino UNO, MFRC522 RFID reader, I2C LCD display, LEDs, buzzer


Skills: Basic Arduino programming, wiring components, using libraries


Component

Description

Arduino UNO (or Nano)

Microcontroller board

MFRC522 RFID Reader

SPI-based RFID module

RFID Tag or Card

13.56 MHz

16x2 I2C LCD Display

For feedback messages

Red and Blue LEDs

Visual access indicators

Piezo Buzzer

For audio feedback

Breadboard + Wires

For prototyping


Here are the Connections for this project

Component

Arduino Pin

MFRC522 SDA

D10

MFRC522 RST

D9

MFRC522 MOSI

D11

MFRC522 MISO

D12

MFRC522 SCK

D13

Red LED

D2

Blue LED

D3

Buzzer

D4

LCD SDA

SDA

LCD SCL

SCL


Before the system can identify your card/tag

You need to know its UID. Upload the following sketch to your Arduino to read the UID of any card you scan:


#include <SPI.h>
#include <MFRC522.h>
#define RST_PIN 9
#define SS_PIN 10

MFRC522 rfid(SS_PIN, RST_PIN);

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  Serial.println("Scan RFID card to see UID:");
}

void loop() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;

  Serial.print("UID tag : ");
  for (byte i = 0; i < rfid.uid.size; i++) {    Serial.print(rfid.uid.uidByte[i] < 0x10 ? " 0" : " ");    Serial.print(rfid.uid.uidByte[i], HEX);
  }
  Serial.println();
  rfid.PICC_HaltA();
  delay(1000);
}

Open your Serial Monitor and scan a tag to get its UID. For example, you might see:

UID tag : 42 F7 C7 01

=====Take note of the value you'll paste them into the main code next.=====



Main Access Control Code

Here’s the final code that checks your scanned UID and shows access status on an LCD with buzzer and LED indicators:


#include <SPI.h>
#include <MFRC522.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

#define RST_PIN 9
#define SS_PIN 10
MFRC522 rfid(SS_PIN, RST_PIN);

LiquidCrystal_I2C lcd(0x27, 16, 2); 

const int redLED = 2;
const int blueLED = 3;
const int buzzer = 4;

byte correctUID[] = {0x42, 0xF7, 0xC7, 0x01}; 

void setup() {
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();

  lcd.init();
  lcd.backlight();

  pinMode(redLED, OUTPUT);
  pinMode(blueLED, OUTPUT);
  pinMode(buzzer, OUTPUT);

  lcd.setCursor(0, 0);
  lcd.print("Scan RFID Card");
}

void loop() {
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial()) return;

  if (isAuthorized(rfid.uid.uidByte)) {
    accessGranted();
  } else {
    accessDenied();
  }

  rfid.PICC_HaltA();
  delay(2000); 
}

bool isAuthorized(byte *uid) 
{
  for (byte i = 0; i < 4; i++) {
    if (uid[i] != correctUID[i]) return false;
  }
  return true;
}

void accessGranted() {
  digitalWrite(redLED, LOW);
  digitalWrite(blueLED, HIGH);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("Welcome User!");
  lcd.setCursor(0, 1);
  lcd.print("Door Opened");

  beep(2, 150);

  delay(3000);
  digitalWrite(blueLED, LOW);
  lcd.clear();
  lcd.print("Scan RFID Card");
}

void accessDenied() {
  digitalWrite(blueLED, LOW);
  digitalWrite(redLED, HIGH);

  lcd.clear();
  lcd.setCursor(0, 0);
  lcd.print("ACCESS DENIED!");
  lcd.setCursor(0, 1);
  lcd.print("No Entry");

  noEntrySound();

  delay(3000);
  digitalWrite(redLED, LOW);
  lcd.clear();
  lcd.print("Scan RFID Card");
}

void beep(int times, int duration) {
  for (int i = 0; i < times; i++) {
    digitalWrite(buzzer, HIGH);
    delay(duration);
    digitalWrite(buzzer, LOW);
    delay(duration);
  }
}

void noEntrySound() {
  for (int i = 0; i < 3; i++) {
    digitalWrite(buzzer, HIGH);
    delay(100);
    digitalWrite(buzzer, LOW);
    delay(50);
  }
}

Have fun with it! Extra Info:

Libraries You’ll Need

Make sure the following libraries are installed via the Library Manager in Arduino IDE:

  • MFRC522 – by GithubCommunity (for RFID)

  • LiquidCrystal_I2C – by Frank de Brabander or compatible fork



How It Works

  • The MFRC522 RFID module waits for a card.

  • When a card is scanned, its UID is compared to the authorized one.

  • If it matches:

    • Blue LED turns on.

    • LCD shows “Welcome User!”

    • Buzzer beeps twice.

  • If it doesn’t match:

    • Red LED turns on.

    • LCD shows “ACCESS DENIED!”

    • Buzzer sounds rapidly 3 times.



To Conclude

This project is a fantastic entry into the world of RFID security systems and helps understand basic authentication logic, peripherals integration, and user feedback mechanisms.

Let me know in the comments if you'd like a version that supports multiple users, EEPROM-based UID saving, or integrates with a web server for logging!

Comments


bottom of page