Performing a function after x time
arduino
Solution
I don't think it's possible to implement since the Arduino does not have an internal clock.
EDIT : It is possible to use the millis() function to calculate an amount of time since the start of the board:
unsigned long previousMillis = 0; // last time update
long interval = 2000; // interval at which to do something (milliseconds)
void setup(){
}
void loop(){
unsigned long currentMillis = millis();
if(currentMillis - previousMillis > interval) {
previousMillis = currentMillis;
// do something
}
}
Problem
What can I use to perform a function in the loop if none of the other conditions in the loop and their code have been executed after a certain amount of time? Can it be done with a delay, or is there some other function?