我正在尝试使用CapSense library for Arduino。但是,我无法运行名为“CapSenseSketch”的软件包附带的示例。当我尝试打开文件并运行它时(我已经尝试过Arduino 1.0和1.0.1),我收到一个编译错误,上面写着'CapSense没有命名类型',还有
CapSenseSketch.cpp:1:22: error: CapSense.h: No such file or directory
CapSenseSketch:11: error: 'CapSense' does not name a type
CapSenseSketch:12: error: 'CapSense' does not name a type
CapSenseSketch:13: error: 'CapSense' does not name a type
CapSenseSketch.cpp: In function 'void setup()':
CapSenseSketch:17: error: 'cs_4_2' was not declared in this scope
CapSenseSketch.cpp: In function 'void loop()':
CapSenseSketch:24: error: 'cs_4_2' was not declared in this scope
CapSenseSketch:25: error: 'cs_4_6' was not declared in this scope
CapSenseSketch:26: error: 'cs_4_8' was not declared in this scope
代码顶部有一个include语句
#include <CapSense.h>
并且我认为这将是问题,因此我将括号更改为引号并仍然出现错误“错误编译”并且:
CapSenseSketch.cpp.o: In function `__static_initialization_and_destruction_0':
CapSenseSketch.cpp:15: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp:16: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp:17: undefined reference to `CapSense::CapSense(unsigned char, unsigned char)'
CapSenseSketch.cpp.o: In function `loop':
CapSenseSketch.cpp:28: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp:29: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp:30: undefined reference to `CapSense::capSense(unsigned char)'
CapSenseSketch.cpp.o: In function `setup':
CapSenseSketch.cpp:21: undefined reference to `CapSense::set_CS_AutocaL_Millis(unsigned long)'
有什么想法吗?我曾在另一台计算机上使用过CapSense,并将括号更改为引号在那段时间内工作正常,但现在似乎没有做太多。
答案 0 :(得分:3)
显然,在arduino ide中包含外部文件的工作方式略有不同。仅仅在代码顶部有一个include语句是不够的,你必须手动转到草图&gt;为要使用的每个外部文件添加文件。在我的情况下,我只对我试图使用的两个文件中的一个执行此操作。