I've been looking through the [source code for ezButton.c][1]

The function `isPressed()` is something of a misnomer and is only meaningful for a push-to-make button on the low side of a pull-up resistor. It actually detects falling edges of the signal, so it should be called `isFallingEdge()`, but the code itself is good.

Similarly for `isReleased()` which detects rising edges of the signal, so should be called `isRisingEdge()`.

The constructor defaults to `INPUT_PULLUP` which may (or may not) be what you want for your buttons and toggle switches, so it's something to bear in mind especially for low-side push-to-break buttons or high-side push-to-make buttons which will generate rising edges when pressed and falling edges when released thus reversing the meanings of `isPressed()` and `isReleased()`, hence why they really should be called `isFallingEdge()` and `isRisingEdge()`.

The algorithm in `ezButton::loop()` could be optimised a bit by getting rid of `previousSteadyState` and nesting the final `if` statement within the second `if` statement.

Other than that, it's quite a good algorithm that makes use of hysteresis to reset the debounce timer.

For comparison you could take a look at my algorithm in this [simple debouncer for Arduino][2] that simply detects rising edges, falling edges or both edges without regard to whether a button was pressed or released, and can be used in a polling loop or with interrupts. Here's the essence of the algorithm:

```c++
    bool input_state = digitalRead(INPUT_PIN);
    unsigned long current_ms = millis();

    edge = rise = fall = false;

    // Hysteresis:
    //   If there is no change, reset the debounce timer.
    //   Else, compare the time difference with the debounce delay.
    if (input_state == output_state)
    {
      last_ms = current_ms;
    }
    else if ((current_ms - last_ms) >= DEBOUNCE_DELAY_ms)
    {
      // Successfully debounced, so update the outputs.
      rise = input_state && !output_state;
      fall = !input_state && output_state;
      edge = rise || fall;
      output_state = input_state;
    }
```

And `ledState = !ledState;` simple toggles the value of `ledState` which is what you write to your LED with `digitalWrite(led1, ledState);` each time a falling edge is detected in the input signal.


  [1]: https://github.com/ArduinoGetStarted/button/blob/master/src/ezButton.cpp
  [2]: https://github.com/TimMathias/Arduino-Debouncer