Page 117 of 346 Start Back Next End ZBasic System Library 105 ZBasic Microcontrollers Delay Type Subroutine Invocation Delay(time) Parameter Method Type Description time ByVal Single The amount of time to delay, in seconds. Discussion This routine suspends the current task for a period of time at least as long as specified. The actual delay depends on what other tasks actually do that may run in the interim. It is possible that the task will be suspended indefinitely depending on what another task might do. If the RTC is not enabled in your application, the resolution of the delay period is 1mS. If the RTC is enabled, the resolution is the same as an RTC tick period, i.e. 1/F_RTC_TICK (typically 1.95mS for ZX devices). Note that if the current task is locked, this call will unlock it. There is a subtle difference between Delay() and Sleep() when the RTC is enabled and the arguments are non-zero. For Delay() the specified time is the minimum amount of delay that the task will experience assuming that no other task is ready to run and the actual delay could be up to 1 unit longer than the specified delay. For Sleep(), the specified time is the maximum amount of delay that the task will experience assuming that no other task is ready to run and the actual delay could be up to 1 unit less than the specified delay. Example Do Call PutPin(Pin.RedLED, 0) Call Delay(0.5) Call PutPin(Pin.RedLED, 1) Call Delay(0.5) Loop This loop causes the red LED to turn on and off alternately for a half second each. Compatibility The BasicX documentation specifically indicates that Delay() will unlock a locked task. However, tests indicate that this only happens if the parameter to Delay() is non-zero. This implementation unlocks a task on any Delay() call. See Also DelayUntilClockTick, Pause, Sleep, Register.RTCStopWatch