Arduino: Project 27: RFID Security System

So I’ve build a authorization system using MFRC522 RFID reader and Arduino.

Hello everyone!! Welcome to this post on Arduino Projects!!
Need a short introduction to what the Arduino is then click on LINK
Check out the breadboard intro right HERE

Demo:

Things Required:

  1. Jumper Wires
  2. Arduino UNO
  3. LED
  4. 10 k potentiometer
  5. 16×2 LCD Screen
  6. RC522 RFID Reader and Tags
  7. USB Cable
  8. Arduino IDE on computer

Reference Material:

  1. Download the RFID library here (Learn how to install libraries) (LINK)
  2. Understanding the SPI library
  3. Helpful video and article1 and article2 for project.

Code:

View on/ Download from Github: (LINK)

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

int rs=2;
int en=3;
int d7=4;
int d6=5;
int d5=6;
int d4=7;

LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int ss_pin= 10;
const int reset_pin=9;

MFRC522 mfrc522(ss_pin, reset_pin);

byte readCard[4];
String master_id= "B2481E39";
String tag_id;

void setup() {
  SPI.begin();
  mfrc522.PCD_Init();
  lcd.begin(16,2);
  lcd.clear();
  lcd.print(" Access Control ");
  lcd.setCursor(0,1);
  lcd.print("Scan Your Card>>");
}

void loop() {
  while(getID()){
    lcd.clear();
    lcd.setCursor(0,0);

    if(tag_id==master_id){
      lcd.print("Access Granted!");
    } else {
      lcd.print("Access Denied!");
    }

    lcd.setCursor(0,1);
    lcd.print(" ID: ");
    lcd.print(tag_id);

    delay(3000);

    lcd.clear();
    lcd.print(" Access Control ");
    lcd.setCursor(0,1);
    lcd.print("Scan Your Card>>");
  }
}

boolean getID(){
  if(!mfrc522.PICC_IsNewCardPresent()){
    return false;
  }

  if(!mfrc522.PICC_ReadCardSerial()){
    return false;
  }

  tag_id="";

  for( uint8_t i=0; i<4; i++){
    tag_id.concat(String(mfrc522.uid.uidByte[i], HEX));
  }

  tag_id.toUpperCase();
  mfrc522.PICC_HaltA();
  return true;
}

Stay Tuned for upcoming posts on Arduino Projects! Want to be the first to know when a new and amazing post comes up?? Then feel free to subscribe!

Happy Learning!!

This image has an empty alt attribute; its file name is stay-tuned.gif

Leave a Reply

PHP JS HTML CSS BASH PYTHON CODE

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.