使用arduino创建找到的Mifare标记列表?
我正在与Arduino Uno和adaFruit PN532董事会合作。目标是能够创建一个目前在NFC盾牌范围内的MiFare卡列表 我很难找到写这个逻辑的最佳方法,因为电路板似乎只检测到每个循环一张卡 我可以在棋盘上放置两张牌,它可以看到两张牌,但每个循环只能看到一张。那么,我如何创建当前范围内的内容的当前列表呢 我的循环:使用arduino创建找到的Mifare标记列表?,arduino,nfc,rfid,arduino-uno,Arduino,Nfc,Rfid,Arduino Uno,我正在与Arduino Uno和adaFruit PN532董事会合作。目标是能够创建一个目前在NFC盾牌范围内的MiFare卡列表 我很难找到写这个逻辑的最佳方法,因为电路板似乎只检测到每个循环一张卡 我可以在棋盘上放置两张牌,它可以看到两张牌,但每个循环只能看到一张。那么,我如何创建当前范围内的内容的当前列表呢 我的循环: void loop() { Serial.println("--------------------Loop begin-------------------")
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*********************");
}
当两个卡都在范围内时,这是串行监视器输出:
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 ****************************循环结束***************************** 您需要一些状态(类似于带有ID和长度字段的结构数组)位于循环的外部来存储(可能有多个)UID。如果有多张卡的话,我认为返回哪个卡的ID可能有点随机 我想您需要继续读取ID,检查数组以查看是否以前见过它,如果没有,则存储它。然后经过一段时间(或数组溢出,或其他一些触发器),您可以打印出“最近”看到的ID,并将数组重置为空(例如,通过清除长度字段)