【问题标题】:"No such file error" when importing PN532Interface.h导入 PN532Interface.h 时出现“无此类文件错误”
【发布时间】:2020-08-08 04:32:05
【问题描述】:

我正在尝试使用 SPI 通信使 NFC 屏蔽工作。 我确实完全按照中的说明遵循了所有说明 Seeed Wiki - NFC Shield Setup.

这是我试过的代码:

#include <SPI.h>
#include <PN532/PN532_SPI/PN532_SPI.h>

PN532_SPI pn532spi(SPI, 10);
NfcAdapter nfc = NfcAdapter(pn532spi);

void setup(void) {
    Serial.begin(115200); // begin serial communication
    Serial.println("NDEF Reader");
    nfc.begin(); // begin NFC communication
}

void loop(void) {

    Serial.println("\nScan an NFC tag\n");
    if (nfc.tagPresent()) // Do an NFC scan to see if an NFC tag is present
    {
        NfcTag tag = nfc.read(); // read the NFC tag into an object, nfc.read() returns an NfcTag object.

        tag.print(); // prints the NFC tags type, UID, and NDEF message (if available)
    }
    delay(500); // wait half a second (500ms) before scanning again (you may increment or decrement the wait time)
}

这是我遇到的错误。

ResolveLibrary(PN532/PN532/PN532Interface.h)
In file included from D:\Dropbox\Ardruino\Seed NFC Reader\Seeed\ReadTagWithSPI

\ReadTagWithSPI.ino:9:0:
  -> candidates: []

C:\Program Files (x86)\Arduino\libraries\Seeed_Arduino_NFC-master

\src/PN532/PN532_I2C/PN532_I2C.h:9:10: fatal error: PN532/PN532/PN532Interface.h: No such file 

or directory

 #include "PN532/PN532/PN532Interface.h"

          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

compilation terminated.

Using library SPI at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino\avr

\libraries\SPI 
Using library PN532_SPI in folder: C:\Program Files (x86)\Arduino\libraries\PN532_SPI (legacy)
Using library Seeed_Arduino_NFC-master at version 1.1.0 in folder: C:\Program Files 

(x86)\Arduino\libraries\Seeed_Arduino_NFC-master 
Using library Wire at version 1.0 in folder: C:\Program Files (x86)\Arduino\hardware\arduino

\avr\libraries\Wire 
exit status 1
Error compiling for board Arduino Uno.

【问题讨论】:

  • 错误信息非常清楚。你错过了一个文件,所以我猜你忘了执行第 3 步?
  • 您是否有明确表示丢失的文件?它在您的计算机上的什么位置?

标签: arduino nfc spi arduino-ide pn532


【解决方案1】:

如果您使用的是 ArduinoIDE,请使用 Sketch -&gt; Manage Libraries -&gt;Library Manager

  • 在搜索字段中输入 PN532 并从那里安装 lib Adafruit PN532

这确保它被放置在正确的目录中。可能您的库与 Afafruit 示例中的不同。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-05
    • 1970-01-01
    • 2021-10-17
    • 2021-03-11
    • 1970-01-01
    • 2015-12-24
    相关资源
    最近更新 更多