Loading
Loading
IoT Lab content is currently available in Arabic only. We're working on an English version.
عرض بالعربية →Reading keyfobs and smart door cards.
Operates at 3.3V, NOT 5V (5V will damage it). SCK to 13, MISO to 12, MOSI to 11, SDA(SS) to 10, RST to 9.
#include <SPI.h>
#include <MFRC522.h>
MFRC522 mfrc522(10, 9);
void setup() {
Serial.begin(9600); SPI.begin(); mfrc522.PCD_Init();
}
void loop() {
if ( ! mfrc522.PICC_IsNewCardPresent() || ! mfrc522.PICC_ReadCardSerial() ) return;
String uid = "";
for (byte i = 0; i < mfrc522.uid.size; i++) {
uid += String(mfrc522.uid.uidByte[i], HEX);
}
Serial.println(uid);
mfrc522.PICC_HaltA();
}Connecting the module's 3.3V power wire to the 5V pin on Arduino.