Skip to the content.

Button Demo 2

This program is demonstrates a timed button press

Hardware required:

This program demonstrates another way to GPIO interrupts. In situations where a number of actions may be executed based on how long a button has been pressed, the typical Timer is not adequate. This example uses the xTaskGetTickCount() function to measure elapsed time around a button press, then takes an appropriate action.

When the program runs, the RGB LED will be one of three colors:

User button 2 is also used as a separate task. This shows how the single ISR can serve multiple FreeRTOS tasks in an independent fashion.

User button 1 is used to toggle a “throb” which manipulates the brightness of the RGB LED color. User button 1 presses < 2 s are ignored, and > 2 s will toggle the throbbing feature.