const int ledPin = 3;
int ledState = LOW; // ledState used to set the LED
unsigned long delay1 = 0; // will store last time LED was updated
void setup() {
// set the digital pin as output:
pinMode(ledPin, OUTPUT);
}
void loop() {
if (millis() - delay1 >= 1000) {
// save the last time you blinked the LED
delay1 = millis();
// if the LED is off turn it on and vice-versa:
if (ledState == LOW) {
ledState = HIGH;
} else {
ledState = LOW;
}
// set the LED with the ledState of the variable:
digitalWrite(ledPin, ledState);
}
}