Example delay timer control using callbacks. More...
#include <AbleButtons.h>
Go to the source code of this file.
Macros | |
#define | BUTTON_PIN 2 |
Connect button between this pin and ground. More... | |
Typedefs | |
using | Button = AblePullupCallbackButton |
Using pull-up button with callbacks. More... | |
using | ButtonList = AblePullupCallbackButtonList |
ButtonList for the same. More... | |
Functions | |
void | holdableCallback (Button::CALLBACK_EVENT event, uint8_t id) |
Callback function for button events. More... | |
void | setup () |
Setup the Debouncable example. More... | |
void | loop () |
Control the Debouncable example. More... | |
Variables | |
Button | btn (BUTTON_PIN, holdableCallback) |
The button to check. | |
Example delay timer control using callbacks.
The built-in LED lights up when a button connected between pin 2 and ground is held down for 2 seconds or more. It uses the internal pull-up resistor within an Arduino for the simplest button connection.
When the button is released, the LED stays on, waiting until idle after 5 seconds and the LED goes off. Simulates a delay timer.
Definition in file HoldableCallback.ino.
#define BUTTON_PIN 2 |
Connect button between this pin and ground.
Definition at line 22 of file HoldableCallback.ino.
using Button = AblePullupCallbackButton |
Using pull-up button with callbacks.
Definition at line 16 of file HoldableCallback.ino.
ButtonList for the same.
Definition at line 17 of file HoldableCallback.ino.
void holdableCallback | ( | Button::CALLBACK_EVENT | event, |
uint8_t | id | ||
) |
Callback function for button events.
event | The event that has occured. |
id | The identifier of the button generating the callback (ignored in this example). |
Definition at line 50 of file HoldableCallback.ino.
void loop | ( | ) |
Control the Debouncable example.
Called repeatedly in a loop.
Definition at line 40 of file HoldableCallback.ino.
void setup | ( | ) |
Setup the Debouncable example.
Called once to initialise everything.
Definition at line 28 of file HoldableCallback.ino.