Advertisement
pleasedontcode

Taskscheduler example

Sep 15th, 2024
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Arduino 0.35 KB | Source Code | 0 0
  1. #include <TaskScheduler.h>
  2.  
  3. Scheduler runner;
  4.  
  5. void task1() {
  6.     // Task 1 code
  7. }
  8.  
  9. void task2() {
  10.     // Task 2 code
  11. }
  12.  
  13. Task t1(1000, TASK_FOREVER, &task1);
  14. Task t2(500, TASK_FOREVER, &task2);
  15.  
  16. void setup() {
  17.     runner.addTask(t1);
  18.     runner.addTask(t2);
  19.     t1.enable();
  20.     t2.enable();
  21. }
  22.  
  23. void loop() {
  24.     runner.execute();
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement