const int button1 = 9;
const int button2 = 10;
const int ledLamp = 11;
int bright = 0;
boolean lastButton1 = LOW;
boolean lastButton2 = LOW;
boolean isSecond1 = LOW;
boolean isSecond2 = LOW;
void setup() {
Serial.begin(9600);
pinMode(button1, INPUT);
pinMode(button2, INPUT);
pinMode(ledLamp, OUTPUT);
}
void loop() {
boolean valueButton1 = digitalRead(button1);
boolean valueButton2 = digitalRead(button2);
delay(10);
if (valueButton1 == HIGH && lastButton1 == LOW) {
Serial.println("Button 1");
if (isSecond1 == HIGH) {
Serial.println("Yes");
isSecond1 = LOW;
bright = bright + 50;
} else {
Serial.println("No");
isSecond1 = HIGH;
}
lastButton1 = HIGH;
} else if (valueButton2 == HIGH && lastButton2 == LOW) {
Serial.println("Button 2");
if (isSecond2 == HIGH) {
Serial.println("Yes");
isSecond2 = LOW;
bright = bright - 50;
} else {
Serial.println("No");
isSecond2 = HIGH;
}
lastButton2 = HIGH;
} else {
lastButton1 = valueButton1;
lastButton2 = valueButton2;
}
if (bright < 0) {
bright = 0;
} else if (bright > 255) {
bright = 255;
}
analogWrite(ledLamp, bright );
}