cfulfordiupucmetBables14
Created April 10, 2019

RFID drawer lock

Electromagnet door lock that unlocks with RFID tag scan

BeginnerWork in progress26
RFID drawer lock

Things used in this project

Story

Read more

Code

Code for rfid door lock

C/C++
load into your arduino
/* 

 * Baby Boilers for TLI -31300 Final Project 
 *
 * RST_PIN AND SS_PIN Are different for varying boards. Check your pin out 
*/

#include <Wire.h>

#include <EEPROM.h>     // We are going to read and write PICC's UIDs from/to EEPROM

#include <MFRC522.h>  // Library for Mifare RC522 Devices



#define RST_PIN         49          // Configurable, see typical pin layout above
#define SS_PIN          53         // Configurable, see typical pin layout above
#define eleMag         7

MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

//Define the character strings for various RFID tags that are allowed 
char caseyTagID[] =  "99 FD E4 2A";  




void setup() {
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522

 pinMode(eleMag, OUTPUT);
 digitalWrite(eleMag,LOW);
}

void loop() {
  
  

 // Look for new cards
  while ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
  digitalWrite(eleMag,LOW);
  }
  // Select one of the cards
  
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
 
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  
  content.toUpperCase();
 

  if (content.substring(1) == "99 FD E4 2A") //change here the UID of the card/cards that you want to give access  99 FD E4 2A
  

  {
    
    digitalWrite(eleMag,HIGH);
   
    
    delay(5000);
    digitalWrite(eleMag,LOW);
   
  }
 
 



}

Credits

cfulford
16 projects • 4 followers
Contact
iupucmet
15 projects • 4 followers
Contact
Bables14
14 projects • 2 followers
Contact

Comments

Please log in or sign up to comment.