我的问题基本上是这样的:我已经安装了CodeBlocks和Arduino插件,并且可以编译并运行测试程序(闪烁的LED),现在我正在尝试编写一个使用以太网模块的测试程序,但是我得到以下错误:
C:\Users\Dai\Documents\Projects\test\sketch.cpp|2|fatal error: Ethernet.h: No such file or directory|
代码如下所示:
#include <Arduino.h>
#include <Ethernet.h>
byte mac[] = {0xDE, 0xAD, 0xBE, 0xEF, 0xFE, 0xED};
byte ip[] {192,168,0,2};
byte gateway[] = {192,168,0,1};
byte subnet[] = {255,255,255,0};
Server server = Server(23);
void setup()
{
pinMode(9, OUTPUT);
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
}
void loop()
{
Client client = server.available();
if(client == true) {
//server.write(client.read());
digitalWrite(9, HIGH);
}
else {
digitalWrite(9, LOW);
}
}
所有列出的头文件及其.cpp文件似乎都存在。
有人能看出我做错了吗?
答案 0 :(得分:0)
这不是您的代码的问题,而是配置。
当编译器看到以下行时,它会尝试包含库文件。
#include <Ethernet.h>
它无法包含它。检查插件以查看库文件的放置位置,并将库文件复制到该目录,并解决您的问题。
答案 1 :(得分:0)
答案可能为时已晚,但只是为了记录;创建一个新项目,右键单击名称 - &gt;递归添加文件 - &gt;浏览你的库文件夹并选择它,点击确定,然后构建,然后......关闭你。
答案 2 :(得分:0)
在Makefile上,找到INCLUDE_LIBS
变量并设置所需的库,例如:
INCLUDE_LIBS=EEPROM;SD;LiquidCrystal;Ethernet;