제품사양
전압: 3~5V
MFRC522
RC522 IC사용
13.56MHZ
소비전류: 20mA 이하
이미지
아두이노 소스코드
//홈페이지: www.daduino.co.kr //이메일: daduino@daduino.co.kr
/* 핀 연결 RST/Reset RST 9 SPI SS SDA(SS) 10 SPI MOSI MOSI 11 SPI MISO MISO 12 SPI SCK SCK 13 */
#include <SPI.h> #include <MFRC522.h>
constexpr uint8_t RST_PIN =
9; // Configurable, see typical pin
layout above constexpr uint8_t SS_PIN =
10; // Configurable, see typical
pin layout above MFRC522 rfid(SS_PIN,
RST_PIN); // Instance of the class
MFRC522::MIFARE_Key key;
// Init array that will
store new NUID byte nuidPICC[4];
void setup() { Serial.begin(9600); SPI.begin(); // Init SPI bus rfid.PCD_Init(); // Init MFRC522
for (byte i = 0; i < 6; i++) { key.keyByte[i] = 0xFF; }
Serial.println(F("This code scan the
MIFARE Classsic NUID.")); Serial.print(F("Using the following
key:")); //printHex(key.keyByte,
MFRC522::MF_KEY_SIZE); } void loop() { // Look for new cards if (rfid.PICC_IsNewCardPresent()) { // Verify if the NUID has been readed if (rfid.PICC_ReadCardSerial()) { Serial.print("value = ");
Serial.print(rfid.uid.uidByte[0],HEX);
Serial.print(rfid.uid.uidByte[1],HEX);
Serial.print(rfid.uid.uidByte[2],HEX);
Serial.print(rfid.uid.uidByte[3],HEX); Serial.println(); // Halt PICC rfid.PICC_HaltA(); // Stop encryption on PCD rfid.PCD_StopCrypto1(); } } } |