Hola Underc0ders, he estado trasteando con el Arduino y con el RFID, mi código no sé porque pero no me hace las instrucciones con la tarjeta, sólo las hace con el llavero RFID.
¿Algun compañerx que me pueda ayudar?
Aquí adjunto el código:
#include <Keyboard.h>
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 5
#define KEY_RETURN 0xB0
MFRC522 mfrc522 ( SS_PIN, RST_PIN ) ;
char Enter = KEY_RETURN;
String readid;
String card1 = "3dfc9562"; // LLAVERO
String card2 = "c2ae7907"; // TARJETA
void setup( )
{
// Serial.begin(9600);
Serial.begin(38400);
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);
readid = readid + String(buffer, 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)
{
Keyboard.releaseAll();
delay (100);
Keyboard.print("dvorak");
Keyboard.releaseAll();
//delay(100);
Keyboard.press(Enter);
Keyboard.releaseAll();
}
else if(readid == card2)
{
Keyboard.releaseAll();
delay (100);
Keyboard.print("qwerty");
Keyboard.releaseAll();
//delay(100);
Keyboard.press(Enter);
Keyboard.releaseAll();
}
else
{
return;
}
}