#include <Toggle.h>
const byte buttonPin = 2;
const byte ledPin = 11;
byte brightness;
bool fadeUp;
Toggle button(buttonPin);
void setup() {
button.begin(buttonPin);
pinMode(ledPin, OUTPUT);
}
void loop() {
button.poll();
if (button.onPress()) fadeUp = !fadeUp;
if (button.isPressed()) {
(fadeUp) ? brightness++ : brightness--;
if (brightness == 255) brightness = 0;
else if (brightness >= 253) brightness = 253;
delay(10);
}
analogWrite(ledPin, brightness);
}