#include <ezButton.h>

ezButton mySwitch(17);  // create ezButton object that attach to pin GPIO17

void setup() {
  // put your setup code here, to run once:
  Serial.begin(115200);
  mySwitch.setDebounceTime(50); // set debounce time to 50 milliseconds
}

void loop() {
  // put your main code here, to run repeatedly:
  mySwitch.loop();  // MUST call loop() function first

  if (mySwitch.isPressed())
    Serial.println("The switch: OFF -> ON");

  if (mySwitch.isReleased())
    Serial.println("The switch: ON -> OFF");

  int state = mySwitch.getState();
  if (state == HIGH)
    Serial.println("The switch: 0FF");
  else
    Serial.println("The switch: ON");
}