V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
IanPeverell
V2EX  ›  Arduino

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

  •  
  •   IanPeverell · Jun 4, 2014 · 7830 views
    This topic created in 4351 days ago, the information mentioned may be changed or developed.
    新人,最近刚学的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 replies    2014-06-05 08:45:51 +08:00
    node
        1
    node  
       Jun 5, 2014   ❤️ 1
    const int LED 9 后面没加分号,先把这个改了再说,C语言编译出错信息只要看第一条就行,改完第一条的错误之后再编译,再出错的话再查新的第一条
    另外i只在loop()里用到,没必要放在全局变量的位置
    nybux
        2
    nybux  
       Jun 5, 2014   ❤️ 1
    const int LED = 9;
    IanPeverell
        3
    IanPeverell  
    OP
       Jun 5, 2014
    @node Arduino编译用的是Processing啊
    IanPeverell
        4
    IanPeverell  
    OP
       Jun 5, 2014
    @nybux
    @node

    问题已解决,Danke
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2528 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 59ms · UTC 09:11 · PVG 17:11 · LAX 02:11 · JFK 05:11
    ♥ Do have faith in what you're doing.