-
-
Notifications
You must be signed in to change notification settings - Fork 80
/
CustomButtonStateHandler.ino
39 lines (27 loc) · 916 Bytes
/
CustomButtonStateHandler.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/////////////////////////////////////////////////////////////////
#include "Button2.h"
/////////////////////////////////////////////////////////////////
Button2 button;
/////////////////////////////////////////////////////////////////
byte myButtonStateHandler() {
return digitalRead(39);
}
/////////////////////////////////////////////////////////////////
void myTapHandler(Button2 &b) {
Serial.println("tap");
}
/////////////////////////////////////////////////////////////////
void setup() {
Serial.begin(115200);
delay(100);
Serial.println("\n\nCustom Buttom Test");
button.begin(BTN_VIRTUAL_PIN);
pinMode(39, INPUT_PULLUP);
button.setButtonStateFunction(myButtonStateHandler);
button.setTapHandler(myTapHandler);
}
/////////////////////////////////////////////////////////////////
void loop() {
button.loop();
}
/////////////////////////////////////////////////////////////////