我一直在使用Arduino的标准代码来使RFID正常工作
#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(); // Initiate SPI 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[i] < 0x10 ? " 0" : " ");
Serial.print(mfrc522.uid.uidByte[i], HEX);
content.concat(String(mfrc522.uid.uidByte[i] < 0x10 ? " 0" : " "));
content.concat(String(mfrc522.uid.uidByte[i], 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);
}
}
我不断收到这些错误
RFID:6: error: 'MFRC522' does not name a type
RFID.ino: In function 'void setup()':
RFID:12: error: 'mfrc522' was not declared in this scope
RFID.ino: In function 'void loop()':
RFID:20: error: 'mfrc522' was not declared in this scope
RFID:25: error: 'mfrc522' was not declared in this scope
RFID:33: error: 'mfrc522' was not declared in this scope
为什么会这样?我正在使用Arduino 1.0.5,因为我的Uno驱动程序不会加载较新的版本。如果已经有关于此的帖子,我找不到它,那么也将附上该链接