Loading...
Searching...
No Matches
Time

millis(), micros(), delay(), delayMicroseconds(). More...

Functions

unsigned long millis (void)
 Milliseconds since the board started.
unsigned long micros (void)
 Microseconds since the board started, with 1 µs resolution (4 µs on an Uno).
void delay (unsigned long)
 Waits a number of milliseconds.
void delayMicroseconds (unsigned int us)
 Waits a number of microseconds, exactly, by busy-waiting.

Detailed Description

millis(), micros(), delay(), delayMicroseconds().

All use the RP2040's microsecond timer, so they are exact at every Tools > CPU Speed setting.

Function Documentation

◆ delay()

void delay ( unsigned long )

Waits a number of milliseconds.

Interrupts, USB Serial and tones keep running. Calls yield() while waiting. With FreeRTOS it blocks the calling task, so other tasks run meanwhile (FreeRTOS).

Examples
AnalogAveraging.ino, AnalogBurst.ino, AnalogDifferential.ino, AnalogMillivolts.ino, AnalogReadMultiple.ino, FreeRtosTasks.ino, I2CScanner.ino, MulticoreBasics.ino, SpiLoopback.ino, and UsbPdPower.ino.

◆ delayMicroseconds()

void delayMicroseconds ( unsigned int us)

Waits a number of microseconds, exactly, by busy-waiting.

Parameters
usTime in µs.

◆ micros()

unsigned long micros ( void )

Microseconds since the board started, with 1 µs resolution (4 µs on an Uno).

Returns
Time in µs. Goes back to 0 after about 71.6 minutes, so compare times by subtracting: micros() - start.

◆ millis()

unsigned long millis ( void )

Milliseconds since the board started.

Returns
Time in ms. Goes back to 0 after about 49.7 days.
Examples
AnalogBurstBackground.ino, FreeRtosQueue.ino, MulticoreFifo.ino, and UsbPdPower.ino.