2014-09-03 12 views
0

我正在使用Arduino Uno和adaFruit PN532板。我们的目标是能够创建一个当前位于NFC Shield范围内的MiFare卡列表。用arduino创建找到的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值:0×13 0x99为0x1C 0xD4

**********************循环结束***** **************

-------------------- Loop begin --------- ----------
实测值的ISO14443A卡
UID长度:4个字节
UID值:0×13 0×27 0x34 0xD4

************* *********循环E ND *******************

回答

0

你需要一些状态(像一个结构的阵列与ID和长度字段)以外的循环来存储您的(可能多个)UID。看看code for readPassiveTargetID我会认为它可能是随机的,如果存在多个卡ID,则返回哪个卡ID。

我想你需要继续阅读ID,检查数组,看看你以前是否看过它,如果没有,就存储它。然后经过一段时间(或数组溢出或其他触发器),您可以打印出您“近期”看到的ID并将阵列重置为空(例如通过清除长度字段)