V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
IanPeverell
V2EX  ›  Arduino

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

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

    问题已解决,Danke
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   4226 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 10:14 · PVG 18:14 · LAX 03:14 · JFK 06:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.