Introduction: Arduino_Wndows_RFID_Lock

Windows 10 is recommended

Step 1: Material

*Hardware

・Arduino Leonardo/Micro/ProMicro Any 1pc

・RFID-RC522 1pc

・Buzzer 1pc

・LED 1pc

・Jump Wire M/M 11pcs

・Breadboard 1pc

*Software

・Arduino IDE
・rfid-master.zip

*/The necessary library is contained in the code file/*

Step 2: Wiring

Arduino Leonardo/Micro pins

RST→RESET/ICSP-5

SDA(SS)→10

MOSI→ICSP-4

MISO→ICSP-1

SCK→ICSP-3

3.3V→3.3V

GND→GND

Arduino ProMicro pins

RST→RST

SDA(SS)→10

MOSI →16

MISO→14

SCK →15

3.3V →vcc

GND→GND


Step 3: Code

<p>/*<br>   Material
   1pcs Arduino Leonaldo/Micro/Pro Micro
   1pcs LED
   1pcs Buzzer
   1pcs RFID(RC522)
   2pcs RFID Card
   RFID(RC522)Aruino Library Download Link → https://github.com/miguelbalboa/rfid
  ============================================================================================
  =              MFRC522      Arduino       Arduino   Arduino    Arduino          Arduino    =
  =              Reader/PCD   Uno/101       Mega      Nano v3    Leonardo/Micro   Pro Micro  =
  =  Signal      Pin          Pin           Pin       Pin        Pin              Pin        =
  ============================================================================================
  =  RST/Reset   RST          9             5         D9         RESET/ICSP-5     RST        =
  =  SPI SS      SDA(SS)      10            53        D10        10               10         =
  =  SPI MOSI    MOSI         11 / ICSP-4   51        D11        ICSP-4           16         =
  =  SPI MISO    MISO         12 / ICSP-1   50        D12        ICSP-1           14         =
  =  SPI SCK     SCK          13 / ICSP-3   52        D13        ICSP-3           15         =
  =  3.3v        3.3v         3.3v          3.3v      3.3v       3.3v             vcc        =
  =  GND         GND          GND           GND       GND        GND              GND        =
  =============================================================================================
*/
#include "Keyboard.h"
#include 
#include 
#define SS_PIN 10
#define RST_PIN 9
// Definicoes pino modulo RC522
MFRC522 mfrc522(SS_PIN, RST_PIN);
// Leds indicadores acesso liberado ou negado
int led = 5;
char st[20];
void setup()
{
  pinMode(led, OUTPUT);
  // Define que o servo esta ligado a porta digital 3
  // Inicia a serial
  Serial.begin(9600);
  // Inicia  SPI bus
  SPI.begin();
  // Inicia MFRC522
  mfrc522.PCD_Init();
  // Mensagens iniciais no serial monitor
  Serial.println("Aproxime o seu cartao do leitor...");
  Serial.println();
}
void loop()
{
  // Aguarda a aproximacao do cartao
  if ( ! mfrc522.PICC_IsNewCardPresent())
  {
    return;
  }
  // Seleciona um dos cartoes
  if ( ! mfrc522.PICC_ReadCardSerial())
  {
    return;
  }
  // Mostra UID na serial
  Serial.print("UID da tag :");
  String conteudo = "";
  byte letra;
  for (byte i = 0; i < mfrc522.uid.size; i++)
  {
    Serial.print(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ");
    Serial.print(mfrc522.uid.uidByte[i], HEX);
    conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
    conteudo.concat(String(mfrc522.uid.uidByte[i], HEX));
  }
  Serial.println();
  Serial.print("Mensagem : ");
  conteudo.toUpperCase();
  // Testa se o cartao1 foi lido
  if (conteudo.substring(1) == "03 2C 07 85")
    //(your UID)First start the serial monitor and check the UID
  {
    // Levanta a cancela e acende o led verde
    digitalWrite(led, HIGH);
    tone(7, 2500, 150);
    Keyboard.press(KEY_LEFT_CTRL);
    Keyboard.press(KEY_LEFT_ALT);
    Keyboard.press(KEY_DELETE);
    delay(100);
    Keyboard.releaseAll();
    delay(200);
    digitalWrite(led, LOW);
    Keyboard.write(KEY_RETURN);
    delay(2000);
    Keyboard.write(KEY_RETURN);
  }
  // Testa se o cartao2 foi lido
  if (conteudo.substring(1) == "9C AF A0 59")
    //(your UID)First start the serial monitor and check the UID
  {  digitalWrite(led, HIGH);
    tone(7, 2500, 150);
    Keyboard.write(KEY_RETURN);
    delay(1500);
    Keyboard.print("your password");//your password
    Keyboard.write(KEY_RETURN);
      digitalWrite(led, LOW);
  }
  delay(1000);
  </p><p>}
/*Maker uomo libero
   Twitter @Creatura18
   Youtube Link https://youtu.be/pGi07C2NSK0
*/</p>

Step 4: Impression / Improvement Points / Questions Etc.

My Maker nickname is uomo libero.
If you have any questions, please contact me on Twitter.@Creatura18