You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Arduino library for handling push buttons just connected between ground and INT0 and / or INT1 pin.<br/>
11
-
12
-
No external pullup, **no polling needed**.
13
-
14
-
The library is totally **based on interrupt** and **debouncing is implemented in a not blocking way**.
15
-
Debouncing is merely done by ignoring a button change within the debouncing time. So **button state is instantly available** without debouncing delay!
16
-
13
+
- No external pullup, **no polling needed**.
14
+
- The library is totally **based on interrupt** and **debouncing is implemented in a not blocking way**.
15
+
Debouncing is merely done by ignoring a button change within the debouncing time (default 50 ms).
16
+
So **button state is instantly available** without debouncing delay!
17
17
- Each button press toggles a state variable, so **no external logic for implementing a toggle button is needed**.
18
-
- Support for **double press detection** is included. See Callback example.
19
-
- Support for **long press detection**, which needs some polling or blocking, is included. See EasyButtonExample example.
20
-
21
-
INT0 and INT1 are connected to:
22
-
- Pin 2 / 3 on most Arduinos (ATmega328*).
23
-
- PB6 / PA3 on ATtiny167. To use one of PA0 to PA7 instead of PA3 just (re)define INT1_PIN before including *EasyButtonAtInt01.cpp.h*. E.g. `#define INT1_PIN 7`. See EasyButtonExample.cpp.
24
-
- Only PB2 / INT0 at on ATtinyX5.
18
+
- Support for **double press detection** is included. See EasyButtonExample and Callback example.
19
+
- Support for **long press detection**, is included. See EasyButtonExample example.
20
+
- Support to **measure maximum bouncing period of a button**. See EasyButtonExample example.
25
21
22
+
## Table of available pins for the 2 buttons
23
+
| CPU | Button 0 | Button 1 using INT1 | Button 1 using PCINT, if INT1_PIN is defined !=3 |
24
+
|-|-|-|-|
25
+
| ATmega328*| D2 | D3 | Pin 0 to 2, 4 to 7 |
26
+
| ATtiny5x | PB2 || PB0 - PB5 |
27
+
| ATtiny167 | PB6 | PA3 | PA0 to PA2, PA4 to PA7 |
26
28
29
+
To use the PCINT buttons instead of the default one, just define INT1_PIN **before** including *EasyButtonAtInt01.cpp.h*.<br/>
30
+
E.g. `#define INT1_PIN 7`. See [EasyButtonExample.cpp](examples/EasyButtonExample/EasyButtonExample.ino#L46).
27
31
28
32
## Usage
29
33
To use a single button, it needs only:
@@ -36,32 +40,36 @@ EasyButton Button0AtPin2;
36
40
void setup() {}
37
41
void loop() {
38
42
...
39
-
digitalWrite(LED_BUILTIN, Button0AtPin2.ButtonToggleState); // initial value is false
43
+
digitalWrite(LED_BUILTIN, Button0AtPin2.ButtonToggleState); // The value at the first call after first press is true
40
44
...
41
45
}
42
46
```
43
47
To use 2 buttons, it needs only:
48
+
44
49
```
45
50
#define USE_BUTTON_0 // Enable code for button at INT0 (pin2)
46
51
#define USE_BUTTON_1 // Enable code for button at INT1 (pin3)
47
52
#include "EasyButtonAtInt01.cpp.h"
48
53
EasyButton Button0AtPin2(true); // true -> Button is connected to INT0 (pin2)
49
-
EasyButton Button0AtPin3(false); // false -> Button is not connected to INT0 => connected to INT1 (pin3)
54
+
EasyButton Button1AtPin3(false); // false -> Button is not connected to INT0 => connected to INT1 (pin3)
0 commit comments