2013-05-08 53 views
2

我正在嘗試使用Arduino時間調度程序。我複製了here的代碼,然後導入了庫,但沒有編譯。這裏的編譯錯誤代碼和代碼本身:Arduino:時間調度程序不起作用

錯誤:

In file included from time2.ino:1: 
C:\arduino\arduino-1.0.3\libraries\Scheduler/Scheduler.h:62: error: 'byte' does not name a type 
C:\arduino\arduino-1.0.3\libraries\Scheduler/Scheduler.h:64: error: 'NUMBER_OF_SCHEDULED_ACTIONS' was not declared in this scope 
C:\arduino\arduino-1.0.3\libraries\Scheduler/Scheduler.h:65: error: 'byte' does not name a type 

代碼:

#include <Scheduler.h> // [url=http://playground.arduino.cc/uploads/Code/Scheduler.zip]Scheduler.zip[/url] 

Scheduler scheduler = Scheduler();  //create a scheduler 

const byte ledPin = 13;    //LED on pin 13 

void setup(){ 
    Serial.begin(9600);     //Iitialize the UART 
    pinMode(ledPin,OUTPUT);    //set pin 13 to OUTPUT 
} 

void loop(){ 
    scheduler.update();     //update the scheduler, maybe it is time to execute a function? 

    if (Serial.available()){   //if we have recieved anything on the Serial 
    scheduler.schedule(setHigh,500); //schedule a setHigh call in 500 milliseconds 
    Serial.flush();     //flush Serial so we do not schedule multiple setHigh calls 
    } 
} 

void setHigh(){ 
    digitalWrite(ledPin,HIGH);   //set ledPin HIGH 
    scheduler.schedule(setLow,500);  //schedule setLow to execute in 500 milliseconds 
} 

void setLow(){ 
    digitalWrite(ledPin,LOW);   //set ledPin LOW 
} 

我怎樣才能解決這個問題?

回答

5

該庫不符合1.0.0+標準。至少

< #include <WProgram.h> 
--- 
> #if defined(ARDUINO) && ARDUINO >= 100 
> #include "Arduino.h" 
> #else 
> #include "WProgram.h" 
> #endif 

然後,它會編譯,對我來說:

更改替換以下\計劃\ Scheduler.h。

+0

thanx的工作將 – mohammad 2013-05-08 17:02:52

+0

@mohammad你也應該接受適合你的答案。這是在這個網站上表達感謝的方式。 – Alexey 2013-05-09 15:46:44