const byte LED_PIN = 13;
const byte UP_BUTTON_PIN = 2; // Connect button between pin and Ground
const byte DOWN_BUTTON_PIN = 3; // Connect button between pin and Ground
byte brightness = 0;
void setup() {
pinMode(LED_PIN, OUTPUT);
pinMode(UP_BUTTON_PIN, INPUT_PULLUP);
pinMode(DOWN_BUTTON_PIN, INPUT_PULLUP);
}
void loop() {
if (digitalRead(UP_BUTTON_PIN) == LOW && brightness < 255)
brightness++;
if (digitalRead(DOWN_BUTTON_PIN) == LOW && brightness > 0)
brightness--;
analogWrite(LED_PIN, brightness);
delay(20); // About 5 seconds from full off to full on
}