Ticker功能测试

#include <Ticker.h>
Ticker tk;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("start cb1");
tk.once_ms(1000,cb1);
Serial.println("start cb3");
tk.attach_ms(400,cb3);
delay(500);
tk.detach();
Serial.println("start cb2");
tk.once_ms(100,cb2);
}

void loop() {
// put your main code here, to run repeatedly:

}
void cb1(){
Serial.println("cb1");
}
void cb2(){
Serial.println("cb2");
}
void cb3(){
Serial.println("cb3");
}

 

 

、、、、、、、、、、、、、、、、、、、、、、、

运行结果:

11:30:36.883 -> start cb1
11:30:36.883 -> start cb3
11:30:37.288 -> cb3
11:30:37.378 -> start cb2
11:30:37.468 -> cb2

 

posted @ 2021-10-25 11:34  chengwh  阅读(177)  评论(0)    收藏  举报