Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
ezeio2:scriptref:sleep [2019-11-19 00:31] – created andreh | ezeio2:scriptref:sleep [2020-08-15 00:12] (current) – andreh | ||
---|---|---|---|
Line 26: | Line 26: | ||
<code javascript> | <code javascript> | ||
- | | + | main() |
- | | + | { |
- | | + | |
+ | sleep(200); // Allow output to be ON for 200 ms | ||
+ | SetOutput(1, | ||
+ | } | ||
</ | </ | ||
+ | An alternative to using the sleep function is to use a timer, like this: | ||
+ | <code javascript> | ||
+ | | ||
+ | { | ||
+ | SetOutput(1, | ||
+ | SetTimer(1, 200); // Set up timer 1 to trip in 200ms | ||
+ | } | ||
+ | |||
+ | | ||
+ | { | ||
+ | SetOutput(1, | ||
+ | | ||
+ | </ | ||
+ | |||
+ | One benefit of using a timer is that you code continues to execute while the timer is running. | ||