millis()
millis()
Tells you how much time has gone by since the Arduino was last turned on, or reset.
Returns
It returns the number of milliseconds that have passed since the Arduino was last turned on, or reset. The number it returns is a long
. It can't count past 50 days, so it resets to 0
after about that much time.
Example
// Turns on the LED 5 seconds after Arduino is reset
if ( millis() > 5000 ) {
awesome.LED.turnOn();
}
Tips
The millis()
function lets you add timing to your project, without using delay()
.