Loading...
Searching...
No Matches

Waiting and timing: delay(), delayMicroseconds(), millis() and micros(). More...

Functions

 delay (ms)
 Waits a number of milliseconds.
 delayMicroseconds (us)
 Waits a number of microseconds.
 millis ()
 Milliseconds since the board started.
 micros ()
 Microseconds since the board started.

Detailed Description

Waiting and timing: delay(), delayMicroseconds(), millis() and micros().

Function Documentation

◆ delay()

delay ( ms)

Waits a number of milliseconds.

The rest of your code waits too; a tone() or analogWrite() carries on. Fractions of a millisecond are dropped.

Parameters
msMilliseconds.

◆ delayMicroseconds()

delayMicroseconds ( us)

Waits a number of microseconds.

Each call takes about 60 us longer than asked: the time MicroPython needs to make the call. So it suits waits of about 100 us and up; for whole milliseconds use delay().

Parameters
usMicroseconds.

◆ millis()

millis ( )

Milliseconds since the board started.

Counts from power-up or RESET; a soft reset (e.g. mpremote soft-reset) doesn't restart it. Never wraps round, as long as it is called at least every 6 days. Use it to time things without stopping your code.

Returns
Milliseconds.

◆ micros()

micros ( )

Microseconds since the board started.

Counts from the same start as millis(). Never wraps round, as long as it is called at least every 8 minutes. The call itself takes tens of us.

Returns
Microseconds.