Prasanth K S
Published © CC BY-NC-SA

Windows PC Lock/Unlock Using RFID

No more hassles of unlocking your computer. Unlock your Windows PC with just a flick of an RFID card/tag.

BeginnerFull instructions provided5 hours92,387
Windows PC Lock/Unlock Using RFID

Things used in this project

Hardware components

Arduino Micro
Arduino Micro
×1
RC-522 RFID Module
×1
Resistor 10k ohm
Resistor 10k ohm
×3

Software apps and online services

Arduino IDE
Arduino IDE

Hand tools and fabrication machines

Soldering iron (generic)
Soldering iron (generic)

Story

Read more

Schematics

Circuit for RFID system

Code

Windows PC lock/unlock using RFID.

C/C++
Arduino Code.
#include <Keyboard.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 5
#define KEY_RETURN 0xB0                 //The hex value for the return key is 0xB0.
 
MFRC522 mfrc522 ( SS_PIN, RST_PIN ) ;
char Enter = KEY_RETURN;                //Return key is declared as Enter.
String readid;
String card1="48b45a10";                //Change this value to the UID of your card.
 
void setup( ) 
{
 Serial.begin(9600);
 Keyboard.begin();
 SPI.begin();
 mfrc522.PCD_Init();
}

void temp(byte *buffer, byte bufferSize)//function to store card uid as a string datatype.
{
  readid="";
  for(byte i = 0;i<bufferSize; i++)
  {
    readid=readid+String(buffer[i], HEX);
  }
}
void loop( ) 
{
 if(!mfrc522.PICC_IsNewCardPresent())
 {
  return;
 }
 if(!mfrc522.PICC_ReadCardSerial()) 
 {
  return;
 }
 mfrc522.PICC_DumpToSerial(&(mfrc522.uid));  // Display card details in serial Monitor.
 temp(mfrc522.uid.uidByte, mfrc522.uid.size);
 if(readid==card1)
 { 
  Keyboard.press(KEY_LEFT_GUI);              //Press the left windows key.
  Keyboard.press('l');                       //Press the "l" key.
  Keyboard.releaseAll();                     //Release all keys.
  delay (100);
  Keyboard.press(Enter);                     //Press the Enter key.
  Keyboard.release(Enter);                   //Release the Enter key.
  delay(100);
  Keyboard.print("PASSWORD");                    // Change this value to your Windows PIN/Password.
  Keyboard.releaseAll();
  delay(100);
  Keyboard.press(Enter);
  Keyboard.releaseAll();
 }
 else
 {
  return;
 } 
}

Credits

Prasanth K S

Prasanth K S

0 projects • 66 followers
Electronics enthusiast, Hardware Maker.

Comments