王梦寒 发表于 2018-5-2 14:00:45

就大神指导一下

我最近做了一个RC522和Arduino相连的系统,功能就是读取卡的信息,为什么一直不成功啊,参照的之前看的一篇。
#include <SPI.h>
#include <MFRC522.h>

#define SS_PIN 10
#define RST_PIN 9
MFRC522 mfrc522(SS_PIN, RST_PIN);   // Create MFRC522 instance.

void setup()
{
Serial.begin(9600);   // Initiate a serial communication
SPI.begin();      // InitiateSPI bus
mfrc522.PCD_Init();   // Initiate MFRC522
Serial.println("Approximate your card to the reader...");
Serial.println();

}
void loop()
{
// Look for new cards
if ( ! mfrc522.PICC_IsNewCardPresent())
{
    return;
}
// Select one of the cards
if ( ! mfrc522.PICC_ReadCardSerial())
{
    return;
}
//Show UID on serial monitor
Serial.print("UID tag :");
String content= "";
byte letter;
for (byte i = 0; i < mfrc522.uid.size; i++)
{
   Serial.print(mfrc522.uid.uidByte < 0x10 ? " 0" : " ");
   Serial.print(mfrc522.uid.uidByte, HEX);
   content.concat(String(mfrc522.uid.uidByte < 0x10 ? " 0" : " "));
   content.concat(String(mfrc522.uid.uidByte, HEX));
}
Serial.println();
Serial.print("Message : ");
content.toUpperCase();
if (content.substring(1) == "BD 31 15 2B") //change here the UID of the card/cards that you want to give access
{
    Serial.println("Authorized access");
    Serial.println();
    delay(3000);
}

else   {
    Serial.println(" Access denied");
    delay(3000);
}
}
为什么复制过去显示什么uidByte【10】有歧义啊,无助
页: [1]
查看完整版本: 就大神指导一下