Created
May 8, 2015 02:55
-
-
Save anonymous/75e8893b85b0171732dc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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