Arduino countdown timer for repeating actions
Something like this would work as a non-blocking, general purpose timer:

unsigned long startTimestamp;
unsigned long timestamp;
const unsigned long timer_length = 10000; //10 seconds

startTimestamp = millis();
timestamp = startTimestamp;

while ( (timestamp - startTimestamp) &lt; timer_length)
{
    // keep doing thing

    timestamp = millis();
}

// stop doing thing now