- Reference
- Script reference
- Timing and scheduling
sleep
Pause script for a short duration
Description#
sleep( milliseconds )
Pause the script for milliseconds.
Parameters#
milliseconds | The duration for which to pause the script |
Return value#
This command does not return a value.
Example usage#
main()
{
SetOutput(1, 100);
sleep(200); // Allow output to be ON for 200 ms
SetOutput(1, 0);
}An alternative to using the sleep function is to use a timer, like this:
main()
{
SetOutput(1, 100); // Turn output on
SetTimer(1, 200); // Set up timer 1 to trip in 200ms
}
@Timer( timerno, timeout, param )
{
SetOutput(1, 0); // Turn output off
} One benefit of using a timer is that you code continues to execute while the timer is running.
Last updated Aug 15, 2020