Last active
December 29, 2015 06:09
-
-
Save rat/7626940 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
// Defining the constants present in the code | |
unsigned long cycle = 300000; | |
unsigned long lastMillis = 0; | |
void setup(){} | |
void loop(){ | |
if(cycleCheck(&lastMillis, cycle)) { | |
// faz o que você quer. | |
} | |
} | |
// function for multitasking | |
// http://arduino.cc/forum/index.php/topic,5686.msg44073.html | |
boolean cycleCheck(unsigned long *lastMillis, unsigned long cycle) { | |
unsigned long currentMillis = millis(); | |
if(currentMillis - *lastMillis >= cycle) { | |
*lastMillis = currentMillis; | |
return true; | |
} | |
else{ | |
return false; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment