新手,碰到了一个问题求指点

2014-06-04 21:34:22 +08:00
 IanPeverell
新人,最近刚学的Arduino,之前看过谭浩强的C语言(手动斜眼)

今天想联系一下,然后就编了一个程序,结果.......

程序是
const int LED 9
int i = 0;

void setup()
{
pinMode(LED, OUTPUT);
}

void loop()
{
for(i=0; i<255; i++)
{
analogWrite(LED, i);
delay(10);
}

for(i = 255; i > 0; i--)
{
analogWrite(LED, i);
delay(10);
}
}

报错是

sketch_jun04a:1: error: expected initializer before numeric constant
sketch_jun04a.ino: In function 'void setup()':
sketch_jun04a:6: error: 'LED' was not declared in this scope
sketch_jun04a.ino: In function 'void loop()':
sketch_jun04a:11: error: 'i' was not declared in this scope
sketch_jun04a:13: error: 'LED' was not declared in this scope
sketch_jun04a:19: error: 'LED' was not declared in this scope
4991 次点击
所在节点    Arduino
4 条回复
node
2014-06-05 02:14:52 +08:00
const int LED 9 后面没加分号,先把这个改了再说,C语言编译出错信息只要看第一条就行,改完第一条的错误之后再编译,再出错的话再查新的第一条
另外i只在loop()里用到,没必要放在全局变量的位置
nybux
2014-06-05 08:38:12 +08:00
const int LED = 9;
IanPeverell
2014-06-05 08:44:03 +08:00
@node Arduino编译用的是Processing啊
IanPeverell
2014-06-05 08:45:51 +08:00
@nybux
@node

问题已解决,Danke

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/115828

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX