inside9
Published © CERN-OHL

Arduino RFID Locker

Easy and safe

BeginnerFull instructions provided507
Arduino RFID Locker

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
×1
Jumper wires (generic)
Jumper wires (generic)
×1
SG90 Micro-servo motor
SG90 Micro-servo motor
×1
9V to Barrel Jack Connector
9V to Barrel Jack Connector
×1
9V battery (generic)
9V battery (generic)
×1
RFID reader (generic)
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Code

RFID Locker

C/C++
#include <Servo.h>
 Servo midway;
#include <SPI.h>
#include <MFRC522.h>
 

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.
int LED = 6; 

 
void setup()
{
    midway. attach(7);
  Serial.begin(9600);   // Initiate a serial communication
  SPI.begin();      // Initiate  SPI bus
  mfrc522.PCD_Init();   // Initiate MFRC522
  Serial.println("Approximate your card to the reader...");
  Serial.println();
  
    pinMode(6, OUTPUT);

}
void loop() 
{

 
  // Look for new cards
  if ( ! mfrc522.PICC_IsNewCardPresent()) 
  {
    return;
  }
  // Select one of the cards
  if ( ! mfrc522.PICC_ReadCardSerial()) 
  {
    return;
  }
  //Show UID on serial monitor
  Serial.print("UID tag :");
  String content= "";
  byte letter;
  for (byte i = 0; i < mfrc522.uid.size; i++) 
  {
     Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
     Serial.print(mfrc522.uid.uidByte[i], HEX);
     content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
     content.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Message : ");
  content.toUpperCase();
  if (content.substring(1) == "79 5E AB 48 , 09 77 60 29=") //change here the UID of the card/cards that you want to give access
  {
    Serial.println("Authorized access");
    Serial.println();
    delay(3000);
  }
 
 else   {
    Serial.println(" Access denied");
   
    digitalWrite(6, HIGH);   // turn the LED 
     delay(1500);
       midway.write(0);
  delay (300);
     digitalWrite(6, LOW);    // turn the LED  LOW
               delay(1500); 
 midway.write(90);
  delay (200);
  }
} 

Credits

inside9
0 projects • 0 followers

Comments