I have an RFID-RC522 module (MF-RC522) and I am using the Arduino sketch program. To use this RFID, I downloaded the Arduino MFRC522 library.
And I run the sample library code.
Here is the code.
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);
void setup() {
Serial.begin(9600);
SPI.begin();
mfrc522.PCD_Init();
Serial.println("Scan PICC to see UID and type...");
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent()) {
return;
}
if ( ! mfrc522.PICC_ReadCardSerial()) {
return;
}
mfrc522.PICC_DumpToSerial(&(mfrc522.uid));
}
When I run this code and put one of the cards in an RFID reader, a lot of information is displayed on the Arduino IDE Serial Monitor. Something like this ... (I could not post the images)
//
Scan PICC to see UID and type...
Card UID : 84 90 6C A7
PICC type : MIFARE 1KB
Sector Block 0 1 2 3 4 5 6 7 ...
15 63 00 00 00 00 ...
//
But I only need a UID card. This case is 84 90 6C A7.
Actually, I have a project. I want to turn on the LED if I put a specific RFID card. To do this, I need to read the UID of the card and assign it to some variable in the Arduino sketch program.
But I do not know how to get the UID of the RFID tag in this case (this library and functions are complicated for me).
- , , , .