gpt4 book ai didi

input - 阿杜伊诺 : time scheduler is not working

转载 作者:行者123 更新时间:2023-12-02 22:03:50 26 4
gpt4 key购买 nike

我正在尝试使用 Arduino 时间调度程序。我从 here 复制了代码我导入了库,但没有编译。这是编译错误代码和代码本身:

错误:

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
}

我该如何解决这个问题?

最佳答案

库不兼容 1.0.0+。

更改替换以下 .\Scheduler\Scheduler.h :

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

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

关于input - 阿杜伊诺 : time scheduler is not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16433802/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com