Skip to content

Instantly share code, notes, and snippets.

@YhanChristian
Created March 31, 2020 13:49
Show Gist options
  • Save YhanChristian/dfdee8cc2d4acac1fcbeb5746c2dd0e5 to your computer and use it in GitHub Desktop.
Save YhanChristian/dfdee8cc2d4acac1fcbeb5746c2dd0e5 to your computer and use it in GitHub Desktop.
int ledState = LOW;
const int ledPin = 13;
unsigned long previousMillis = 0;
const long interval = 1000;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop()
{
unsigned long currentMillis = millis();
if(currentMillis - previousMillis >= interval) {
previousMillis = currentMillis;
if (ledState == LOW)
ledState = HIGH;
else
ledState = LOW;
digitalWrite(ledPin, ledState);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment