IanPeverell
V2EX  ›  Arduino

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

  •  
  •   IanPeverell · Jun 4, 2014 · 12620 views
    This topic created in 4559 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
    node
    Jun 5, 2014❤️1
    1
    const int LED 9 后面没加分号,先把这个改了再说,C语言编译出错信息只要看第一条就行,改完第一条的错误之后再编译,再出错的话再查新的第一条
    另外i只在loop()里用到,没必要放在全局变量的位置
    nybux
    nybux
    Jun 5, 2014❤️1
    2
    const int LED = 9;
    IanPeverell
    IanPeverell
    OP
    Jun 5, 2014
    3
    @node Arduino编译用的是Processing啊
    IanPeverell
    IanPeverell
    OP
    Jun 5, 2014
    4
    @nybux
    @node

    问题已解决,Danke
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   1882 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 15:32 · PVG 23:32 · LAX 07:32 · JFK 10:32
    ♥ Do have faith in what you're doing.