Created
March 31, 2020 13:49
-
-
Save YhanChristian/dfdee8cc2d4acac1fcbeb5746c2dd0e5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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