#include <ezButton.h>
// define buttons with ezButton
ezButton btn2(2);
ezButton btn3(3);
ezButton btn4(4);
// define led pin
const int ledPin = 8;
int step = 0;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
// set btn debounce time
btn2.setDebounceTime(50);
btn3.setDebounceTime(50);
btn4.setDebounceTime(50);
// led pin as output
pinMode(ledPin, OUTPUT);
}
void loop() {
btn2.loop();
btn3.loop();
btn4.loop();
if (btn2.isPressed() && step == 1) {
Serial.println("step 2");
step++;
return;
}
if (btn3.isPressed() && step == 0) {
Serial.println("step 1");
step++;
return;
}
if (btn4.isPressed() && step == 2) {
Serial.println("success");
digitalWrite(ledPin, HIGH);
delay(4000);
digitalWrite(ledPin, LOW);
}
if (btn2.isPressed() || btn3.isPressed() || btn4.isPressed()) {
Serial.println("reset");
step = 0;
return;
}
}