1

Scheduler_example00_Blink is ~300 lines. For just an Arduino Uno, what is a minimal example?

It's hard to know what belongs and what doesn't. This example has six different approaches, and I'm just trying to extract one of them.

asked Mar 17, 2021 at 16:47
3
  • what about the scheduler template? Commented Mar 17, 2021 at 17:01
  • 2
    the main GitHub page for the library has a link to an awesome web based Arduino emulator .... wokwi.com/playground/task-scheduler ... try deleting sections of code until you are left with minimum Commented Mar 17, 2021 at 22:15
  • i don't see it as being personal ... i am glad that you were able to work through it ... learning experience ... please don't forget to accept your own answer Commented Mar 23, 2021 at 22:20

1 Answer 1

1
#include <TaskScheduler.h>
// Scheduler
Scheduler ts;
/*
 Approach 1: LED is driven by the boolean variable; false = OFF, true = ON
*/
#define PERIOD1 500
#define DURATION 10000
void blink1CB(); // <-------------------------------------------|
Task tBlink1 ( PERIOD1 * TASK_MILLISECOND, DURATION / PERIOD1, &blink1CB, &ts , true );
// ( 500 * 1UL (ms) , 100000 ms/ 500 , function , just put it, ? )
void setup()
{
 pinMode(LED_BUILTIN, OUTPUT);
}
void loop()
{
 ts.execute();
}
inline void LEDOn() {
 digitalWrite( LED_BUILTIN, HIGH );
}
inline void LEDOff() {
 digitalWrite( LED_BUILTIN, LOW );
}
// === 1 =======================================
bool LED_state = false;
void blink1CB()
{
 if ( LED_state )
 {
 LEDOff();
 LED_state = false;
 }
 else
 {
 LEDOn();
 LED_state = true;
 }
}
answered Mar 23, 2021 at 16:35

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.