Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Millis Delay Example
const int ledPin = 13;
int ledState = LOW;
long previousTime = 0;
long interval = 1000;
void setup() {
pinMode(ledPin, OUTPUT);
}
void loop()
{
unsigned long currentTime = millis();
if(currentTime - previousTime > interval) {
previousTime = currentTime;
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
You can’t perform that action at this time.