AbleButtons V0.4.0
Lightweight button library for Arduino.
 
Loading...
Searching...
No Matches
HoldableCallback.ino File Reference

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.
 

Detailed Description

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.

Macro Definition Documentation

◆ BUTTON_PIN

#define BUTTON_PIN   2

Connect button between this pin and ground.

Definition at line 22 of file HoldableCallback.ino.

Typedef Documentation

◆ Button

Using pull-up button with callbacks.

Definition at line 16 of file HoldableCallback.ino.

◆ ButtonList

ButtonList for the same.

Definition at line 17 of file HoldableCallback.ino.

Function Documentation

◆ holdableCallback()

void holdableCallback ( Button::CALLBACK_EVENT  event,
uint8_t  id 
)

Callback function for button events.

Parameters
eventThe event that has occured.
idThe identifier of the button generating the callback (ignored in this example).

Definition at line 50 of file HoldableCallback.ino.

◆ loop()

void loop ( )

Control the Debouncable example.

Called repeatedly in a loop.

Definition at line 40 of file HoldableCallback.ino.

◆ setup()

void setup ( )

Setup the Debouncable example.

Called once to initialise everything.

Definition at line 28 of file HoldableCallback.ino.