const int ledPin = 9;
const int button1 = 2;
const int button2 = 3;
const int button3 = 4;
int brightness1 = 85; // ~33% (PWM: 0–255)
int brightness2 = 170; // ~66%
int brightness3 = 255; // 100%
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(button1, INPUT_PULLUP);
pinMode(button2, INPUT_PULLUP);
pinMode(button3, INPUT_PULLUP);
}
void loop() {
if (digitalRead(button1) == LOW) {
analogWrite(ledPin, brightness1);
} else if (digitalRead(button2) == LOW) {
analogWrite(ledPin, brightness2);
} else if (digitalRead(button3) == LOW) {
analogWrite(ledPin, brightness3);
}
}