这是一个创建于 3792 天前的主题,其中的信息可能已经有所发展或是发生改变。
新人,最近刚学的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
4 条回复 • 2014-06-05 08:45:51 +08:00
|
|
1
node 2014-06-05 02:14:52 +08:00 1
const int LED 9 后面没加分号,先把这个改了再说,C语言编译出错信息只要看第一条就行,改完第一条的错误之后再编译,再出错的话再查新的第一条 另外i只在loop()里用到,没必要放在全局变量的位置
|
|
|
2
nybux 2014-06-05 08:38:12 +08:00 1
const int LED = 9;
|