RFID Access System

Build a simple access control system that identifies authorized RFID cards and key tags.

Components Needed

Arduino Uno

RC522 RFID Module

RFID Card


RFID Key Tag

Jumper Wires

⚠️ Important: RC522 uses 3.3V, not 5V.

  • How It Works

    RFID cards and key tags contain unique identification numbers called UIDs. The RC522 reader scans these UIDs and sends them to the Arduino. The Arduino can then decide whether the scanned card is authorized or not.

  • What You'll Learn

    RFID Technology
    SPI Communication
    Reading Card UIDs
    Access Control Logic
    Using Arduino Libraries

  • Step 1 — Read Your Card UID

    This first sketch simply prints the UID of any card or key tag you scan.

    The user should:

    1. Upload the code.
    2. Open Serial Monitor.
    3. Scan the card.
    4. Copy the UID.
  • Code 1: UID Reader

    #include <SPI.h>
    #include <SPI.h>

    #define SS_PIN 10
    #define RST_PIN 9

    MFRC522 rfid(SS_PIN, RST_PIN);

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

    Serial.println("Scan your RFID card...");
    }

    void loop() {

    if (!rfid.PICC_IsNewCardPresent())
    return;

    if (!rfid.PICC_ReadCardSerial())
    return;

    Serial.print("UID: ");

    for (byte i = 0; i < rfid.uid.size; i++) {
    Serial.print(rfid.uid.uidByte[i], HEX);
    Serial.print(" ");
    }

    Serial.println();
    }

  • Step 2 — Authorized Access

    Now the user takes the UID from Step 1 and places it into the authorized list.

  • Code 2: Access Control

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

    #define SS_PIN 10
    #define RST_PIN 9

    MFRC522 rfid(SS_PIN, RST_PIN);

    byte authorizedUID[4] = {0xDE, 0xAD, 0xBE, 0xEF};

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

    Serial.println("RFID Access System Ready");
    }

    void loop() {

    if (!rfid.PICC_IsNewCardPresent())
    return;

    if (!rfid.PICC_ReadCardSerial())
    return;

    bool authorized = true;

    for (byte i = 0; i < 4; i++) {
    if (rfid.uid.uidByte[i] != authorizedUID[i]) {
    authorized = false;
    break;
    }
    }

    if (authorized) {
    Serial.println("Access Granted");
    } else {
    Serial.println("Access Denied");
    }

    delay(1000);
    }

  • Result

    When a card is scanned:

    ✅ Authorized UID → Access Granted

    ❌ Unknown UID → Access Denied