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.

3
  • what about the scheduler template?
    – jsotola
    Mar 17 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
    – jsotola
    Mar 17 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
    – jsotola
    Mar 23 at 22:20
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;
  }
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.