Skip to content

Instantly share code, notes, and snippets.

Created May 8, 2015 02:55
Show Gist options
  • Save anonymous/75e8893b85b0171732dc to your computer and use it in GitHub Desktop.
Save anonymous/75e8893b85b0171732dc to your computer and use it in GitHub Desktop.
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
char st[20];
void setup()
{
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
}
void loop()
{
if ( ! mfrc522.PICC_IsNewCardPresent())
{
return;
}
if ( ! mfrc522.PICC_ReadCardSerial())
{
return;
}
// Muestra el UID de la tag
String conteudo= "";
byte letra;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
conteudo.concat(String(mfrc522.uid.uidByte[i], HEX));
}
conteudo.toUpperCase();
if (conteudo.substring(1) == "4D AF 90 55")
{
Serial.print('A');
}
if (conteudo.substring(1) == "11 90 D0 0E")
{
Serial.print('B');
}
delay(1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment