AbleButtons
V0.4.0
Lightweight button library for Arduino.
Loading...
Searching...
No Matches
Buttonable.ino
Go to the documentation of this file.
1
/**
2
* @file Buttonable.ino Example on/off control from an Able button.
3
*
4
* This shows how Able can be used to create the same program as the built-in
5
* [Button example](https://www.arduino.cc/en/Tutorial/BuiltInExamples/Button)
6
* included with the Arduino IDE.
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
* NB: This example uses direct pin reading which is not debounced. Contact
13
* bouncing can make the button's signal unstable for a few ms when pressed or
14
* released.
15
*
16
* @copyright Copyright (c) 2022 John Scott
17
*/
18
#include <
AbleButtons.h
>
19
20
// Identify which buttons you are using...
21
using
Button
=
AblePullupDirectButton
;
///< Using the direct pull-up button.
22
using
ButtonList
=
AblePullupDirectButtonList
;
///< Using the direct pull-up button list.
23
24
#define BUTTON_PIN 2
///< Connect button between this pin and ground.
25
Button
btn
(
BUTTON_PIN
);
///< The button to check.
26
27
/**
28
* Setup the Buttonable example. Called once to initialise everything.
29
*/
30
void
setup
() {
31
btn
.
begin
();
32
pinMode(LED_BUILTIN, OUTPUT);
33
}
34
35
/**
36
* Control the Buttonable example. Called repeatedly in a loop.
37
*/
38
void
loop
() {
39
btn
.
handle
();
40
41
digitalWrite(LED_BUILTIN,
btn
.
isPressed
());
42
}
AbleButtons.h
The main include file for the Arduino Button library Extension (ABLE).
AblePullupDirectButton
able::Button< able::PullupResistorCircuit, able::Pin > AblePullupDirectButton
AblePullupDirectButton provides basic button is-pressed capability for buttons connected using pull-u...
Definition:
AbleButtons.h:215
AblePullupDirectButtonList
able::ButtonList< AblePullupDirectButton > AblePullupDirectButtonList
AblePullupDirectButtonList allows an array of AblePullupDirectButton objects to be managed together.
Definition:
AbleButtons.h:280
setup
void setup()
Setup the Buttonable example.
Definition:
Buttonable.ino:30
BUTTON_PIN
#define BUTTON_PIN
Connect button between this pin and ground.
Definition:
Buttonable.ino:24
btn
Button btn(BUTTON_PIN)
The button to check.
loop
void loop()
Control the Buttonable example.
Definition:
Buttonable.ino:38
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
Buttonable
Buttonable.ino
Generated by
1.9.5