Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/arduino/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Input Arduino:时间调度程序不工作_Input_Arduino_Multiprocessing - Fatal编程技术网

Input Arduino:时间调度程序不工作

Input Arduino:时间调度程序不工作,input,arduino,multiprocessing,Input,Arduino,Multiprocessing,我正在尝试使用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:6

我正在尝试使用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
代码:

#包括//[url=http://playground.arduino.cc/uploads/Code/Scheduler.zip]Scheduler.zip[/url]
调度程序=调度程序()//创建调度程序
常量字节ledPin=13//引脚13上的LED
无效设置(){
Serial.begin(9600);//初始化UART
引脚模式(LED引脚,输出);//将引脚13设置为输出
}
void循环(){
scheduler.update();//更新调度器,也许是执行函数的时候了?
if(Serial.available()){//如果我们在序列号上收到任何信息
scheduler.schedule(setHigh,500);//在500毫秒内安排setHigh调用
Serial.flush();//flush Serial,这样我们就不会安排多个setHigh调用
}
}
void setHigh(){
digitalWrite(LED引脚,高);//将LED引脚设置为高
scheduler.schedule(setLow,500);//计划在500毫秒内执行setLow
}
void setLow(){
digitalWrite(ledPin,低);//将ledPin设置为低
}

如何修复此问题?

库不符合1.0.0+标准

更改或替换以下内容。\Scheduler\Scheduler.h:

<#包括
---  
>#如果定义(ARDUINO)&&ARDUINO>=100
>#包括“Arduino.h”
>#其他
>#包括“WProgram.h”
>#endif

然后它会编译,至少对我来说。

@mohammad你也应该接受对你有用的答案。这是在这个网站上表达感谢的方式。
#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
}