Using RFID to Lock/Unlock computer

Introduction

In this DIY, we will make a device to unlock our computer running on any operating system using an RFID card.   We just needed to pass the card above the RFID reader, in my case I have placed it inside my laptop housing.

As you can see in the picture, I have removed the CD drive and placed an SSD and on top of that, you can see our RFID reader with Arduino Leonardo.

Hardware Required

ComponentsDIY UsthaddiyusthadAmazon.comamazonBanggoodbanggoodAliExpressali expressUtsource
utsource logo
RFID RC522cart iconcart iconcart iconcart icon
Arduino Leonardocart iconcart iconcart iconcart iconcart icon

Pinout Diagram

RFID RC522 Pinout by thepinout.tech
Arduino leonardo pinout ICSP

Circuit


As shown in the circuit give the connections as follows:

Arduino Leo              RFID        
 MOSI   MOSI 
 MISO    MISO  
 PIN 10     SDA
 PIN 9   RESET
 SCK  SCK
 3.3V  VCC
 GND   GND 

Setup

After building the circuit please upload the program and open the serial monitor and scan your RFID which you need to set as your computer key and note down the RFID number which is printed on the serial monitor and update that number in the program (line 10);

Also, update your password (line 48) in the program and upload the program again. Now We are ready to go.

Watch the video

Code

#include 
#include 
#include 

#define SS_PIN 10
#define RST_PIN 9

RFID rfid(SS_PIN, RST_PIN);

int serNum[5];
int card[5] = {198, 65, 184, 121, 70};
boolean password=LOW;
void setup()
{
  Serial.begin(9600);
  SPI.begin();
  rfid.init();

}

void loop()
{
  if (rfid.isCard())
  {
    Serial.println("card available");
    if (rfid.readCardSerial())
    {

      for (int x = 0; x < 10; x++)
      {
        for (int i = 0; i < sizeof(rfid.serNum); i++ )
        {
          if (rfid.serNum[i] == card[i])
          {
            password = HIGH;
            Serial.println(rfid.serNum[i]);
            break;
          }
        }
      }
    }
  }
  if (password == HIGH)
  {
    
    Keyboard.press(0xB1);
    delay(300);
    Keyboard.print("your password");
    Keyboard.press(0xB0);
    delay(50);
    Keyboard.releaseAll();
    delay(100);
    Keyboard.end();
    password=LOW;
  }
}

Scroll to Top