ourutopia 发表于 2014-11-13 21:39:58

servo库为啥无法使用,无法创建对象

打开自带的sweep例子都编译不了,老报这错误,用别的库没问题啊……



Sweep:12: error: 'Servo' does not name a type
Sweep.ino: In function 'void setup()':
Sweep:19: error: 'myservo' was not declared in this scope
Sweep.ino: In function 'void loop()':
Sweep:26: error: 'myservo' was not declared in this scope
Sweep:31: error: 'myservo' was not declared in this scope

a1039752256 发表于 2014-11-13 22:14:04

有没有include "Servo.h" ?

ourutopia 发表于 2014-11-13 22:24:44

a1039752256 发表于 2014-11-13 22:14 static/image/common/back.gif
有没有include "Servo.h" ?

肯定引入啦,用的自带的例子哇

a1039752256 发表于 2014-11-13 22:27:50

ourutopia 发表于 2014-11-13 22:24 static/image/common/back.gif
肯定引入啦,用的自带的例子哇

贴上源码看看

ourutopia 发表于 2014-11-13 22:31:50

找到原因了!

我用的eclipse arduino,所有的库文件首位都被加了
#ifdef ARDUINO_ARCH_SAM
#ifdef ARDUINO_ARCH_AVR



#endif /* ARDUINO_ARCH_AVR */
#endif /* ARDUINO_ARCH_SAM */

然后就不好使了,为什么我也不知道,我重新复制了库文件过来就好了。
这个问题是我用文件比较软件发现的……

我用其他库没问题是因为我用到的其他库都是配置完eclipse arduino之后复制过来的,所以文件没有被改掉,所以就好使。

Super169 发表于 2014-11-15 01:10:23

我用的eclipse arduino

下次如果不是用原本的 IDE, 應該一早說明吧.不把重點說清楚就發問, 只會浪費大家的時間.
页: [1]
查看完整版本: servo库为啥无法使用,无法创建对象