const int ledPin = 2;
const int buttonPin1 = 25;
const int buttonPin2 = 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(ledPin, OUTPUT);
pinMode(buttonPin1, INPUT_PULLUP);
pinMode(buttonPin2, INPUT_PULLUP);
}
void loop() {
unsigned long currentMillis = millis();
buttonState1 = digitalRead(buttonPin1);
buttonState2 = digitalRead(buttonPin2);
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(ledPin, ledState);
}