编写一个使用CLRC663的读typeA卡的代码
时间: 2023-04-01 08:01:48 浏览: 91
以下是使用CLRC663读取typeA卡的代码示例:
#include <SPI.h>
#include <Adafruit_PN532.h>
#define SCK 13
#define MOSI 11
#define SS 10
#define MISO 12
Adafruit_PN532 nfc(SCK, MISO, MOSI, SS);
void setup(void) {
Serial.begin(115200);
nfc.begin();
uint32_t versiondata = nfc.getFirmwareVersion();
if (! versiondata) {
Serial.print("Didn't find PN53x board");
while (1); // halt
}
Serial.print("Found chip PN5"); Serial.println((versiondata>>24) & xFF, HEX);
Serial.print("Firmware ver. "); Serial.print((versiondata>>16) & xFF, DEC);
Serial.print('.'); Serial.println((versiondata>>8) & xFF, DEC);
nfc.SAMConfig();
Serial.println("Waiting for an ISO14443A Card ...");
}
void loop(void) {
uint8_t success;
uint8_t uid[] = { , , , , , , }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
Serial.println("Found an ISO14443A card");
Serial.print("UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print("UID Value: ");
for (uint8_t i=; i < uidLength; i++) {
Serial.print(" x");Serial.print(uid[i], HEX);
}
Serial.println("");
delay(100);
}
}