#include <ezButton.h>
#include <MsTimer2.h>
ezButton button(7); // create ezButton object that attach to pin 7;
int count = 0;
int next = 0;
int total = 0;
void setup() {
Serial.begin(115200);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
}
void loop()
{if(button.isPressed())
count=1;
buttoncount();
}
void buttoncount()
{
button.loop(); // MUST call the loop() function first
if(button.isPressed())
{Serial.println("The button is pressed - count");
count = count +1 ;
Serial.println(count);
total = count + next;
Serial.print("total is = ");
Serial.println(total);
}
if(button.isReleased())
{
next = next +1 ;
Serial.println("The button is released - next");
Serial.println(next);
total = count + next;
Serial.print("total is = ");
Serial.println(total);
}
return 0;
}