Created
February 17, 2020 17:32
-
-
Save yeffrimic/8d9c11ae333de75e42c0f2fa0a1756c9 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
/* | |
* RFID wemos | |
* | |
* feb 2020 | |
* Yeffrimic,Xibalba Hackerspace. | |
* | |
*/ | |
#include <SPI.h> | |
#include <MFRC522.h> | |
#define RST_PIN D4 | |
#define SS_PIN D8 | |
MFRC522 mfrc522(SS_PIN, RST_PIN); | |
void setup() { | |
Serial.begin(115200); | |
SPI.begin(); | |
mfrc522.PCD_Init(); | |
mfrc522.PCD_DumpVersionToSerial(); | |
Serial.println(F("Scan PICC to see UID, SAK, type, and data blocks...")); | |
} | |
void loop() { | |
// Look for new cards | |
if ( ! mfrc522.PICC_IsNewCardPresent()) { | |
delay(50); | |
return; | |
} | |
// Select one of the cards | |
if ( ! mfrc522.PICC_ReadCardSerial()) { | |
delay(50); | |
return; | |
} | |
Serial.print(F("Card UID:")); | |
dump_byte_array(mfrc522.uid.uidByte, mfrc522.uid.size); | |
Serial.println(); | |
} | |
void dump_byte_array(byte *buffer, byte bufferSize) { | |
for (byte i = 0; i < bufferSize; i++) { | |
Serial.print(buffer[i] < 0x10 ? " 0" : " "); | |
Serial.print(buffer[i], HEX); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment