#define LED 2
#define BUTTON1 25
#define BUTTON2 35
int ledState = LOW;
int buttonState1 = HIGH;
int buttonState2 = HIGH;
int lastButtonState2 = HIGH;
unsigned long previousMillis = 0;
const long onInterval = 3000;
long offInterval = 1000;
void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON1, INPUT_PULLUP);
pinMode(BUTTON2, INPUT_PULLUP);
}
void loop() {
unsigned long currentMillis = millis();
buttonState1 = digitalRead(BUTTON1);
buttonState2 = digitalRead(BUTTON2);
if (buttonState1 == LOW) {
ledState = !ledState;
previousMillis = currentMillis;
}
if (buttonState2 == LOW && lastButtonState2 == HIGH) {
if (offInterval == 1000) {
offInterval = 3000;
} else {
offInterval = 1000;
}
}
lastButtonState2 = buttonState2;
if (ledState == HIGH && currentMillis - previousMillis >= onInterval) {
ledState = LOW;
previousMillis = currentMillis;
} else if (ledState == LOW && currentMillis - previousMillis >= offInterval) {
ledState = HIGH;
previousMillis = currentMillis;
}
digitalWrite(LED, ledState);
}