Skip to content
schlammbad edited this page Feb 21, 2024 · 5 revisions

Below are the descriptions of the included examples. You can find these in the Library menu item.

BlinkUsingTaskFunctions

This demonstrates the use of the FunctionTask feature of Task library. It will use tasks to blink an LED repeatedly without the use of delay(). In this example, tasks are declared at the top and are associated with a function that will be run when the task gets called to update. The tasks will continuously toggle their running state; starting the other, which will turn off and on the LED.

BlinkUsingTaskMacros

This demonstrates the use of the Task macros feature of Task library. It will use a custom task defined using the helper macros to blink an LED repeatedly. This is intended for intermediate level coders where more control is needed. This exposes to the developer the functions that are called when the task is started and stopped along with updated. The custom task is defined in the taskBlinkLed.h tab.

BlinkUsingCustomTask

This demonstrates the use of the custom Task object feature of Task library. It will use a custom task to blink a LED repeatedly. This is intended for advanced level coders where the most control is required and knowledge of C++ is understood.

ButtonTask

This demonstrates the use of the custom Task object feature of Task library.
It will instance two custom ButtonTasks to monitor two different pins and make a call back when they change state; with de-bounce and auto repeat support.

This requires two momentary buttons attached to any io pins and ground. One button will turn on the onboard LED when it is pressed down, the other button turn off the onboard LED when it is released. Both will send useful information to the serial monitor.
The custom task is defined in the ButtonTask.h tab.

ButtonInterrupt

NOTE: Due to differences between how CPU architectures sleep, this example is aimed at AVR chipsets.

This demonstrates the use of the Sleep feature of the Task library.
It will instance two custom ButtonTasks to monitor two different pins and call back when they change state; with de-bounce and auto repeat support. An external interrupt is tied to the buttons to wake the Arduino up on any button press. There are two tasks implementing a LED Blink showing a "heartbeat" that can only run when awake. There is a task that will put the Arduino into a deep sleep 15 seconds after any button press.

This requires two momentary buttons attached any io pins and ground. This requires a diode per button be attached between the button pin and a single external interrupt pin. The cathode (black band) end of the diode is attached to the button pin; the anode to the interrupt pin.

MessageTask

This demonstrates the use of the message passing feature of Task library. It will instance two custom ButtonTasks to monitor two different pins and they will send messages when they change state. It will also have tasks that provide a heartbeat message.

This requires two momentary buttons attached between pins 4 & 5 and ground, you can change the pins to any digital pin

RotaryEncoder

This demonstrates creating a task to manage the details of rotary encoder. The task will track a value and increment and decrement it when the encoder is rotated. It will also provide a callback so the application can respond. Further, it provides a de-bounced button callback for the encoder press feature.

This requires a common rotary encoder be connected to available pins.