【发布时间】:2020-07-17 22:58:44
【问题描述】:
我想用一个简单的例子来测试我的新 GPS 板 (NEO-M9N):
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The serial connection to the GPS device
SoftwareSerial ss(RXPin, TXPin);
void setup()
{
Serial.begin(115200);
ss.begin(GPSBaud);
}
void loop()
{
// Output raw GPS data to the serial monitor
while (ss.available() > 0){
Serial.write(ss.read());
}
}
但是,当我尝试在我的 arduino nano 33 ble 上运行它时,我收到了这个错误:
SoftwareSerial.h: No such file or directory
我需要做什么才能使用 arduino nano 33 ble 运行此代码?
【问题讨论】:
-
你在库管理器中安装了库吗?
-
SoftwareSerial.h的完整路径是什么? (例如)如果是/foo/bar/baz/include/SoftwareSerial.h,您需要将-I/foo/bar/baz/include添加到编译器命令行。但是,它可能没有被安装。通常,给定包的配置脚本可以告诉您.h和.so文件的安装位置(例如pkg-config)。顺便说一句,基于SoftwareSerial ss(RXPin, TXPin);和ss.begin(GPSBaud),这是not 有效的c代码。看起来有点像c++。 -
我用我的 Arduino Uno 尝试了这段代码,它成功了。只有我的 Arduino Nano 33 BLE Sense 有问题。