Project showcase
RFID Identification With LEDs

RFID Identification With LEDs © CC BY-NC-ND

A RFID module connected to two LEDs.

  • 28,636 views
  • 9 comments
  • 54 respects

Components and supplies

Apps and online services

About this project

I'm a beginner and I love the Arduino! This is a project for beginners like myself! :)

When the RFID-RC522 scans the card, the card's key will appear in the serial monitor. And if the NFC card is accepted, the green LED will be on, and if the card is not accepted, the red LED will be on.

This is the library for the project : https://github.com/miguelbalboa/rfid

If you like this project, follow me and respect the project!

Code

RFID with LEDs C/C++
#include "SPI.h"
#include "MFRC522.h"

#define SS_PIN 10
#define RST_PIN 9
#define LED_PIN A0 
#define LED_PIN A1

MFRC522 rfid(SS_PIN, RST_PIN);

MFRC522::MIFARE_Key key;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  SPI.begin();
  rfid.PCD_Init();
  pinMode(A0, OUTPUT);
  pinMode(A1, OUTPUT);
  Serial.println("I am waiting for card...");
}

void loop() {
  // put your main code here, to run repeatedly:
  if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())
    return;

  // Serial.print(F("PICC type: "));
  MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
  // Serial.println(rfid.PICC_GetTypeName(piccType));

  // Check is the PICC of Classic MIFARE type
  if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
      piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
      piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
    Serial.println(F("Your tag is not of type MIFARE Classic."));
    return;
  }
  String strID = "";
  for (byte i = 0; i < 4; i++) {
    strID +=
      (rfid.uid.uidByte[i] < 0x10 ? "0" : "") +
      String(rfid.uid.uidByte[i], HEX) +
      (i != 3 ? ":" : "");
  }

  strID.toUpperCase();
  Serial.print("Tap card key: ");
  Serial.println(strID);
  delay(1000);

  if (strID.indexOf("20:CC:6F:85") >= 0) {  //put your own tap card key;
    Serial.println("********************");
    Serial.println("**Authorised acces**");
    Serial.println("********************");
    digitalWrite(A0, HIGH);
    delay (5000);
    digitalWrite(A0, LOW);
    return;
  }
  else {
    Serial.println("****************");
    Serial.println("**Acces denied**");
    Serial.println("****************");
    digitalWrite(A1, HIGH);
    delay (5000);
    digitalWrite(A1, LOW);
    return;
  }
  
}

Schematics

RFID-RC522 WITH LEDs
rfid-rc522_with_leds_PJyl6FiRbc.fzz

Comments

Similar projects you might like

DHT11 Sensor with LEDs and a Piezo Speaker

Project tutorial by PrinceMatthew

  • 21,515 views
  • 4 comments
  • 31 respects

Security Access Using RFID Reader

by Aritro Mukherjee

  • 472,966 views
  • 71 comments
  • 499 respects

RFID Badge Scanner with LCD

by Josh From BreakoutBros.com

  • 24,484 views
  • 4 comments
  • 47 respects

Blinking LEDs with Arduino

Project tutorial by Super Kid

  • 7,716 views
  • 3 comments
  • 21 respects

RFID Based Automatic Door System

Project showcase by Robodia Technology

  • 77,373 views
  • 32 comments
  • 164 respects

Arduino Ethernet Rfid card reader

Project tutorial by David Smerkous

  • 55,686 views
  • 18 comments
  • 78 respects
Add projectSign up / Login