#include <ezButton.h>
#include <ArduinoTrace.h>
#include <ptScheduler.h>
ezButton button(7); // create ezButton object that attach to pin 7;
bool buttonIsLow=false;
byte count;
ptScheduler Task1Sch = ptScheduler(1000000); //on period
ptScheduler Task2Sch = ptScheduler(100000);
void setup() {
Serial.begin(9600);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
DUMP(count);
}
void loop() {
button.loop(); // MUST call the loop() function first
if(button.getState()==LOW)
{
buttonIsLow=true;
}
else
{
buttonIsLow=false;
}
if(Task1Sch.call()) Task1();
if(Task2Sch.call()) Task2();
}
void Task1()
{
if(buttonIsLow==false)
{
count++;
DUMP(count);
}
if(buttonIsLow){
count--;
DUMP(count);
}
}
void Task2(){
}