int ledPin = 13;
int switchPin = 5;
int ledState = LOW;
unsigned long previousMillis = 0;
long interval = 100;
boolean running = false;
void setup() {
pinMode(ledPin, OUTPUT); // put your setup code here, to run once:
pinMode(switchPin, INPUT_PULLUP);
digitalWrite(switchPin, HIGH);
}
void loop() {
if (digitalRead(switchPin) == LOW){
unsigned long currentMillis = millis(); // put your main code here, to run repeatedly:
if (currentMillis - previousMillis > interval){
previousMillis = currentMillis ;
running = !running;
digitalWrite(ledPin, running);
}
}
}