You are viewing an older revision! See the latest version
Timeout
The Timeout interface is used to setup an interrupt to call a function after a specified delay.
Any number of Timeout objects can be created, allowing multiple outstanding interrupts at the same time.
Hello World!¶
A simple program to setup a Timeout to invert an LED after a given timeout...
#include "mbed.h" Timeout flipper; DigitalOut led1(LED1); DigitalOut led2(LED2); void flip() { led2 = !led2; } int main() { led2 = 1; flipper.attach(&flip, 2.0); // setup flipper to call flip after 2 seconds // spin in a main loop. flipper will interrupt it to call flip while(1) { led1 = !led1; wait(0.2); } }