我想问问这是哪里出现问题了呀,求大神大家指点,帮帮...

2023-08-205734
AI 快速预览详细 收起
本文讨论了在使用DFRobot RFID门禁系统时遇到的“RFID.h: No such file or directory”编译错误。文章详细介绍了如何解决该问题,包括检查库文件路径、重新安装库文件等步骤。通过这些方法,您可以快速定位并解决编译错误,确保门禁系统的正常运行。


#include <SPI.h>
#include <RFID.h>
#include <Servo.h>

RFID rfid(10, 9);      
unsigned char status;
unsigned char str[MAX_LEN];

String accessGranted [2] = {"15301511012", "5305151412"};  //序列号位置
int accessGrantedSize = 2;                                //几个卡号

Servo lockServo;               
int lockPos = 15;              
int unlockPos = 75;            
boolean locked = true;

int redLEDPin = 5;
int greenLEDPin = 6;

void setup()
{
  Serial.begin(9600);     //Serial monitor is only required to get tag ID numbers and for troubleshooting
  SPI.begin();            //Start SPI communication with reader
  rfid.init();            //initialization
  pinMode(redLEDPin, OUTPUT);     //LED startup sequence
  pinMode(greenLEDPin, OUTPUT);
  digitalWrite(redLEDPin, HIGH);
  delay(200);
  digitalWrite(greenLEDPin, HIGH);
  delay(200);
  digitalWrite(redLEDPin, LOW);
  delay(200);
  digitalWrite(greenLEDPin, LOW);
  lockServo.attach(3);
  lockServo.write(lockPos);         //Move servo into locked position
  Serial.println("Place card/tag near reader...");
}

void loop()
{
  if (rfid.findCard(PICC_REQIDL, str) == MI_OK)   //Wait for a tag to be placed near the reader
  {
    Serial.println("Card found");
    String temp = "";                             //Temporary variable to store the read RFID number
    if (rfid.anticoll(str) == MI_OK)              //Anti-collision detection, read tag serial number
    {
      Serial.print("The card's ID number is : ");
      for (int i = 0; i < 4; i++)                 //Record and display the tag serial number
      {
        temp = temp + (0x0F & (str >> 4));
        temp = temp + (0x0F & str);
      }
      Serial.println (temp);
      checkAccess (temp);     //Check if the identified tag is an allowed to open tag
    }
    rfid.selectTag(str); //Lock card to prevent a redundant read, removing the line will make the sketch read cards continually
  }
  rfid.halt();
}

void checkAccess (String temp)    //Function to check if an identified tag is registered to allow access
{
  boolean granted = false;
  for (int i=0; i <= (accessGrantedSize-1); i++)    //Runs through all tag ID numbers registered in the array
  {
    if(accessGranted == temp)            //If a tag is found then open/close the lock
    {
      Serial.println ("Access Granted");
      granted = true;
      if (locked == true)         //If the lock is closed then open it
      {
          lockServo.write(unlockPos);
          locked = false;
      }
      else if (locked == false)   //If the lock is open then close it
      {
          lockServo.write(lockPos);
          locked = true;
      }
      digitalWrite(greenLEDPin, HIGH);    //Green LED sequence
      delay(200);
      digitalWrite(greenLEDPin, LOW);
      delay(200);
      digitalWrite(greenLEDPin, HIGH);
      delay(200);
      digitalWrite(greenLEDPin, LOW);
      delay(200);
    }
  }
  if (granted == false)     //If the tag is not found
  {
    Serial.println ("Access Denied");
    digitalWrite(redLEDPin, HIGH);      //Red LED sequence
    delay(200);
    digitalWrite(redLEDPin, LOW);
    delay(200);
    digitalWrite(redLEDPin, HIGH);
    delay(200);
    digitalWrite(redLEDPin, LOW);
    delay(200);
  }


D:\打包解压RFID项目\RFID\RFID.ino:4:10: fatal error: RFID.h: No such file or directory
compilation terminated.

exit status 1

Compilation error: RFID.h: No such file or directory


创作许可协议

本项目采用 None(不开放任何权利,保留所有权利) 进行许可。

评论(6)
ljs硬件
ljs硬件
库文件装错了吧,要装到.../项目文件夹/libraries/,要是解压后的文件夹,项目文件夹地址在文件->首选项里查看
ljs硬件
ljs硬件回复ljs硬件
把“#include”中的<>换成""试试
ljs硬件
ljs硬件回复ljs硬件
或者C:\Users\(用户名)\AppData\Local\Arduino15\libraries
花生编程
花生编程
重装一下
花生编程
花生编程
没有库了吧
9mm
9mm
重装就可以了
三春牛-创客
三春牛-创客
重新安装一下
三春牛-创客
三春牛-创客
应该是库文件没有了
- 没有更多了 -