ezeio2:scriptref:sleep

Pause script for a short duration

Description

sleep( milliseconds )

Pause the script for milliseconds.

USE WITH CAUTION

This command will prevent events to be executed and may cause unwanted delays in other logic.

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.

  • ezeio2/scriptref/sleep.txt
  • Last modified: 2020-08-15 00:12
  • by andreh