#include <ezButton.h>
#define RESET_PIN 3
#define LED_PIN1 4
#define LED_PIN2 5
#define LED_PIN3 6
#define LED_PIN4 7
ezButton button(2); // create ezButton object that attach to pin 7;
unsigned long lastCount = 0;
unsigned long count = 0;
void setup() {
Serial.begin(9600);
button.setDebounceTime(50); // set debounce time to 50 milliseconds
button.setCountMode(COUNT_FALLING);
pinMode(LED_PIN1, OUTPUT);
pinMode(LED_PIN2, OUTPUT);
pinMode(LED_PIN3, OUTPUT);
pinMode(LED_PIN4, OUTPUT);
pinMode(RESET_PIN, OUTPUT);
void(* resetFunc) (void) = 0;
}
void loop() {
button.loop(); // MUST call the loop() function first
count = button.getCount();
if (count != lastCount) {
Serial.println(count);
digitalWrite(RESET_PIN, HIGH);
int countIn3 = count % 5 + 1;
switch (countIn3) {
case 1:
digitalWrite(LED_PIN1, HIGH);// TO DO TASK 1
break;
case 2:
digitalWrite(LED_PIN2, HIGH);// TO DO TASK 2
break;
case 3:
digitalWrite(LED_PIN3, HIGH);// TO DO TASK 3
break;
case 4:
digitalWrite(LED_PIN4, HIGH);// TO DO TASK 3
break;
case 5:
digitalWrite(RESET_PIN, LOW);
break;
}
lastCount = count;
}
}