Last active
June 10, 2022 17:28
-
-
Save lcsjunior/885e74adb530a96e65187de8f53768d9 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
// Globals | |
unsigned long previousMillis = 0; | |
const long eventInterval = 5000; | |
// ... | |
// Blocking "like delay()" | |
unsigned long start = millis(); | |
while (millis() - start <= eventInterval) { | |
// ... | |
} | |
// Non-blocking | |
unsigned long currentMillis = millis(); | |
// ... | |
if (currentMillis - previousMillis >= eventInterval) { | |
previousMillis = currentMillis; | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment