// https://wokwi.com/projects/408186995430496257
// https://forum.arduino.cc/t/nrf24l01-transmits-button-press-1-3-times-then-fails/1298615
# include <ezButton.h>
const byte selectDelay = 7;
const byte theLED = 6;
const byte busyLED = 8;
ezButton button(3);
void setup() {
Serial.begin(115200);
Serial.println("Hello ezButton does it suck World!\n");
button.setDebounceTime(25); // set debounce time to 25 milliseconds PLENTY.
pinMode(theLED, OUTPUT);
pinMode(busyLED, OUTPUT);
pinMode(selectDelay, INPUT_PULLUP); // closed switch == LOW, no delay
}
static int counter;
void loop() {
static unsigned long lastTime;
unsigned long now = millis();
button.loop();
if (button.isPressed()) {
digitalWrite(theLED, digitalRead(theLED) == LOW ? HIGH : LOW); // toggle the LED
Serial.print(counter); counter++;
if (digitalRead(selectDelay) == LOW) {
Serial.println(" I saw that.");
}
else {
Serial.print(" I saw that. Sleeping for a bit...");
delay(223);
digitalWrite(busyLED, HIGH);
delay(777);
digitalWrite(busyLED, LOW);
Serial.println(" and back on the job.");
}
}
}
BLOCKING
LED
< <TOGGLE?
<BLOCK