#SHININGkeystroke

Dernière modification : 2017/11/20 17:14



#include <Keyboard.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 2
#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="UIDCARD";                //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));
 temp(mfrc522.uid.uidByte, mfrc522.uid.size);
 if(readid==card1)
 { 
  delay(100);
  Keyboard.println("Qll zork qnd no plqy ;qkes Jqck q dull boy");
  delay(100);
  Keyboard.press(Enter);                     //Press the Enter key.
  Keyboard.release(Enter);                   //Release the Enter key.
 }
 else
 {
  return;
 } 
}