AbleButtons
V0.4.0
Lightweight button library for Arduino.
Loading...
Searching...
No Matches
Buttonable2.ino
Go to the documentation of this file.
1
/**
2
* @file Buttonable2.ino Example on/off control from a button. Similar to the
3
* Buttonable example, except this example uses a debounced pin.
4
*
5
* NB: All that's changes is the `using Button` and `using ButtonList` lines at
6
* the beginning of the program to select debounced reading capability.
7
*
8
* The built-in LED lights when a button connected between pin 2 and ground is
9
* pressed. It uses the internal pull-up resistor within an Arduino for the
10
* simplest button connection.
11
*
12
* @copyright Copyright (c) 2022 John Scott
13
*/
14
#include <
AbleButtons.h
>
15
16
// Identify which buttons you are using...
17
using
Button
=
AblePullupButton
;
///< Using basic pull-up button.
18
using
ButtonList
=
AblePullupButtonList
;
///< Using basic pull-up button list.
19
20
#define BUTTON_PIN 2
///< Connect button between this pin and ground.
21
Button
btn
(
BUTTON_PIN
);
///< The button to check.
22
23
/**
24
* Setup the Buttonable2 example. Called once to initialise everything.
25
*/
26
void
setup
() {
27
btn
.
begin
();
28
pinMode(LED_BUILTIN, OUTPUT);
29
}
30
31
/**
32
* Control the Buttonable2 example. Called repeatedly in a loop.
33
*/
34
void
loop
() {
35
btn
.
handle
();
36
37
digitalWrite(LED_BUILTIN,
btn
.
isPressed
());
38
}
AbleButtons.h
The main include file for the Arduino Button library Extension (ABLE).
AblePullupButtonList
able::ButtonList< AblePullupButton > AblePullupButtonList
Handler for list of AblePullupButton objects.
Definition:
AbleButtons.h:245
AblePullupButton
able::Button< able::PullupResistorCircuit, able::DebouncedPin > AblePullupButton
AblePullupButton provides basic button is-pressed capability for buttons connected using pull-up resi...
Definition:
AbleButtons.h:175
setup
void setup()
Setup the Buttonable2 example.
Definition:
Buttonable2.ino:26
BUTTON_PIN
#define BUTTON_PIN
Connect button between this pin and ground.
Definition:
Buttonable2.ino:20
btn
Button btn(BUTTON_PIN)
The button to check.
loop
void loop()
Control the Buttonable2 example.
Definition:
Buttonable2.ino:34
able::Button
Core Button class.
Definition:
Button.h:22
able::Button::begin
void begin()
Initialise the button.
Definition:
Button.h:60
able::Button::handle
void handle()
Handle the button.
Definition:
Button.h:67
able::Button::isPressed
bool isPressed() const
Determine if the button is currently pressed.
Definition:
Button.h:127
able::ButtonList
Template for a list of buttons of the same type.
Definition:
ButtonList.h:20
AbleButtons
examples
Buttonable2
Buttonable2.ino
Generated by
1.9.5