本帖最后由 ntwhq 于 2013-8-25 15:45 编辑
编程时想自己写一个库,但编译时总是出错,找不出原因,我就把为LED闪烁程序做试验写了一个最简单的库,但编译时还是出错,请大家帮我找找原因。
两个库文件:
LED.h:
[mw_shl_code=cpp,true]#ifndef LED_h
#define LED_h
#if ARDUINO >= 100
#include "Arduino.h"
#else
#include "WProgram.h"
#endif
class LED
{
byte _pin;
public:
LED(byte pin);
void on();
void off();
};
#endif
[/mw_shl_code]
LED.cpp:
[mw_shl_code=cpp,true]#include "LED.h"
LED:ED(byte pin)
{
_pin=pin;
pinMode(pin,OUTPUT);
}
void LED:n()
{
digitalWrite(_pin,HIGH);
}
void LED:ff()
{
digitalWrite(_pin,LOW);
}[/mw_shl_code]
程序代码:
[mw_shl_code=cpp,true]#include <LED.h>
void setup()
{
LED.LED(13);
}
void loop()
{
LED.on();
delay(1000);
LED.off();
delay(1000);
}[/mw_shl_code]
编译后出现如下界面:
出错信息为:
LED.ino: In function 'void setup()':
LED:4: error: expected unqualified-id before '.' token
LED.ino: In function 'void loop()':
LED:8: error: expected unqualified-id before '.' token
LED:10: error: expected unqualified-id before '.' token
反复试了也查不出错误的原因,请各位高手指教一下错在哪里,谢谢!
|