Timers

setTimeout(function_handler, timeout_ms)
clearTimeout(timer_id)
setInterval(function_handler, interval_ms)
clearInterval(timer_id)

Example:

function sample() {
  print("Sampling sensor...");
}

function setup() {
  setInterval(sample, 1000); // Sample every second
}

The xxxTimeout functions schedule the given function to be called after a given number of milliseconds. After the function is handled, the timer is expired and never fired again.

The xxxInterval function schedule a reoccurring invocation of the given function at a fixed interval. This will continue forever until the timer is canceled, or the module is deactivated.