ezeio2:scriptref:sleep

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
ezeio2:scriptref:sleep [2019-11-19 00:31] – created andrehezeio2:scriptref:sleep [2020-08-15 00:12] (current) andreh
Line 26: Line 26:
  
 <code javascript>     <code javascript>    
-   SetOutput(1, 100); +   main() 
-   sleep(100);             // Allow output to be ON for 100 ms +   { 
-   SetOutput(1, 0);+      SetOutput(1, 100); 
 +      sleep(200);             // Allow output to be ON for 200 ms 
 +      SetOutput(1, 0); 
 +   }
 </code> </code>
  
 +An alternative to using the sleep function is to use a timer, like this:
  
 +<code javascript>    
 +   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
 +   }  
 +</code>
 +
 +One benefit of using a timer is that you code continues to execute while the timer is running.
  
  
  • ezeio2/scriptref/sleep.1574123503.txt.gz
  • Last modified: 2019-11-19 00:31
  • by andreh