Subversion Repositories ESP8266_P1_Meter

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
2 raymond 1
/*
2
 * Created by ArduinoGetStarted.com
3
 *
4
 * This example code is in the public domain
5
 *
6
 * Tutorial page: https://arduinogetstarted.com/tutorials/arduino-button-library
7
 *
8
 * This example:
9
 *   + uses debounce for a button.
10
 *   + reads state of a button
11
 *   + detects the pressed and released events of a button
12
 */
13
 
14
#include <ezButton.h>
15
 
16
ezButton button(7);  // create ezButton object that attach to pin 7;
17
 
18
void setup() {
19
  Serial.begin(9600);
20
  button.setDebounceTime(50); // set debounce time to 50 milliseconds
21
}
22
 
23
void loop() {
24
  button.loop(); // MUST call the loop() function first
25
 
26
  int btnState = button.getState();
27
  Serial.println(btnState);
28
 
29
  if(button.isPressed())
30
    Serial.println("The button is pressed");
31
 
32
  if(button.isReleased())
33
    Serial.println("The button is released");
34
}