sleep


void sleep(const long nMSec)

Parameter Explanation Data Type
Return Type The function returns no value. void
nMSec The amount of milliseconds to wait long
  • Program execution will wait for the specified number of clock units. Units are in 1-millisecond counts.
  • It is best to use the sleep function to insert a programmed delay in a program because tasks that are waiting do not consume any CPU cycles. This makes the most number of CPU cycles available for other tasks.

  • This command is exactly the same as the wait1MSec() and delay() commands

Code Sample

// The program will wait for 1 second before continuing to the next line of code (1ms * 1000)

sleep(1000);