#include <ezButton.h>
ezButton button(7); // create ezButton object that attach to pin 7;
unsigned long lastCount = 0;
unsigned long count = 0;
int prevcount;
int counter = 0;
void setup() {
Serial.begin(9600);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
button.setCountMode(COUNT_FALLING);
}
void loop() {
button.loop(); // MUST call the loop() function first
Serial.println(counter);
count = button.getCount();
if (count != lastCount) {
Serial.println(count);
int countIn3 = count % 2 + 1;
switch (countIn3) {
case 1:
Serial.println("press 2");
break;
case 2:
Serial.println("press 1");
prevcount = counter;
counter++;
delay(1000);
break;
}
lastCount = count;
}
}