我正在使用 Arduino Uno 和 adaFruit PN532 板。目标是能够创建当前在 NFC Shield 范围内的 MiFare 卡列表。
我无法找出编写此逻辑的最佳方法,因为电路板似乎每个循环只能检测到一张卡。
我可以在板上放两张牌,它可以同时看到它们,但每个循环只能看到一张。那么我将如何创建当前范围内的当前列表
我的循环:
void loop()
{
Serial.println("--------------------Loop begin-------------------");
uint8_t success;
uint8_t uid[] = { 0, 0, 0, 0, 0, 0, 0 }; // Buffer to store the returned UID
uint8_t uidLength; // Length of the UID (4 or 7 bytes depending on ISO14443A card type)
uint8_t index =0;
// Wait for an ISO14443A type cards (Mifare, etc.). When one is found
// 'uid' will be populated with the UID, and uidLength will indicate
// if the uid is 4 bytes (Mifare Classic) or 7 bytes (Mifare Ultralight)
success = nfc.readPassiveTargetID(PN532_MIFARE_ISO14443A, uid, &uidLength);
if (success) {
// Display some basic information about the card
Serial.println("Found an ISO14443A card");
Serial.print(" UID Length: ");Serial.print(uidLength, DEC);Serial.println(" bytes");
Serial.print(" UID Value: ");
nfc.PrintHex(uid, uidLength);
Serial.println("");
}
Serial.println("************************Loop END*********************");
}
当两张卡都在范围内时,这是串行监视器:
--------------------循环开始--------
找到一张 ISO14443A 卡
UID 长度:4 字节
UID 值:0x13 0x99 0x1C 0xD4************************循环结束************************
--------------------循环开始-------------------
找到一个 ISO14443A 卡
UID 长度:4 字节
UID 值:0x13 0x34 0x27 0xD4************************循环结束************************