-
-
Save chepecarlos/b75af33d6df46433bbc8 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> | |
//Librerias del RFID y SPI | |
#define SS_PIN 10 | |
#define RST_PIN 9 | |
//Pines de selecion y resetiar | |
MFRC522 mfrc522(SS_PIN, RST_PIN); | |
//Crear la intancia para habla con RFID | |
char st[20]; | |
//Donde se guarda el ID | |
void setup() | |
{ | |
Serial.begin(9600); | |
//Puerto serial con la PC | |
SPI.begin(); | |
mfrc522.PCD_Init(); | |
// Inicializa el spi y RFID | |
} | |
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++) {//Obtiene el tamaño y recore todo el data | |
conteudo.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " ")); | |
conteudo.concat(String(mfrc522.uid.uidByte[i], HEX)); | |
//Saca la data y la trasfroma en algo entendible | |
} | |
conteudo.toUpperCase(); | |
//Pone en mayusculas con contenido conteudo | |
if (conteudo.substring(1) == "4D AF 90 55") { | |
Serial.print('A'); | |
} | |
//Compara contra el ID 1 | |
if (conteudo.substring(1) == "11 90 D0 0E") { | |
Serial.print('B'); | |
} | |
//Compara contra el ID 1 | |
delay(1000); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment