极客工坊

 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 14968|回复: 5

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

[复制链接]
发表于 2014-11-13 21:39:58 | 显示全部楼层 |阅读模式
打开自带的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

回复

使用道具 举报

发表于 2014-11-13 22:14:04 | 显示全部楼层
有没有include "Servo.h" ?
回复 支持 反对

使用道具 举报

 楼主| 发表于 2014-11-13 22:24:44 | 显示全部楼层
a1039752256 发表于 2014-11-13 22:14
有没有include "Servo.h" ?

肯定引入啦,用的自带的例子哇
回复 支持 反对

使用道具 举报

发表于 2014-11-13 22:27:50 | 显示全部楼层
ourutopia 发表于 2014-11-13 22:24
肯定引入啦,用的自带的例子哇

贴上源码看看
回复 支持 反对

使用道具 举报

 楼主| 发表于 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之后复制过来的,所以文件没有被改掉,所以就好使。
回复 支持 反对

使用道具 举报

发表于 2014-11-15 01:10:23 | 显示全部楼层
我用的eclipse arduino


下次如果不是用原本的 IDE, 應該一早說明吧.  不把重點說清楚就發問, 只會浪費大家的時間.  
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|联系我们|极客工坊

GMT+8, 2026-6-15 19:33 , Processed in 0.044728 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表