// led pin const int ledPin1 = 13; // button pin const int buttonPin1 = 2; // blinking delay const int interval1 = 500; bool ledState1; bool canBlink1; unsigned long previousMillis1; void setup() { pinMode(ledPin1, OUTPUT); // set led pin to output pinMode(2, INPUT_PULLUP); // button pin set to INPUT with internal PULLUP(default state will be HIGH) } void loop() { unsigned long currentMillis = millis(); bool buttonState1 = digitalRead(buttonPin1); if (buttonState1 == LOW) { while (digitalRead(buttonPin1) == LOW); if (digitalRead(buttonPin1) == HIGH) { canBlink1 = !canBlink1; digitalWrite(ledPin1, LOW); } } if (currentMillis - previousMillis1 >= interval1 && canBlink1) { previousMillis1 = currentMillis; ledState1 = !ledState1; digitalWrite(ledPin1, ledState1); } }