#define SWITCH_PIN 12
#define LED_PIN 25
void setup() {
Serial.begin(115200);
pinMode(SWITCH_PIN, INPUT_PULLUP);
pinMode(LED_PIN, OUTPUT);
digitalWrite(LED_PIN, LOW);
}
void loop() {
static bool ledState = false;
static bool lastSwitchState = HIGH;
bool currentSwitchState = digitalRead(SWITCH_PIN);
if(lastSwitchState == HIGH && currentSwitchState == LOW) {
ledState = !ledState;
digitalWrite(LED_PIN, ledState ? HIGH : LOW);
}
lastSwitchState = currentSwitchState;
}