-
-
Notifications
You must be signed in to change notification settings - Fork 65
/
Copy pathTouchButton.ino
42 lines (33 loc) · 899 Bytes
/
TouchButton.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
40
41
42
/*
Name: TouchButton.ino
Created: 6/25/2019 9:25:52 AM
Author: Evert Arias
Description: Example to demostrate how to use the library to detect a single touch.
*/
#include <EasyButtonTouch.h>
// Arduino pin where the button is connected to.
#define BUTTON_PIN 27
#define BAUDRATE 115200
// Instance of the button.
EasyButtonTouch button(BUTTON_PIN);
// Callback function to be called when the button is pressed.
void onPressed()
{
Serial.println("Button has been pressed");
}
void setup()
{
// Initialize Serial for debuging purposes.
Serial.begin(BAUDRATE);
Serial.println();
Serial.println(">>> EasyButton touch button example <<<");
// Initialize the button.
button.begin();
// Add the callback function to be called when the button is pressed.
button.onPressed(onPressed);
}
void loop()
{
// Continuously read the status of the button.
button.read();
}