Jose Rios
/
Nucleo_BlinkTimer
Blinking a LED using the timer (timeout object)
main.cpp
- Committer:
- jose_23991
- Date:
- 2014-10-29
- Revision:
- 0:7eabe79006b3
File content as of revision 0:7eabe79006b3:
#include "mbed.h" #define TIME 1 // Time for toggle the LED (seconds) DigitalOut led(LED1, 0); // Create the LED object and setup OFF Timeout timeout; // Create the Timeout object void timer_interrupt() { led = !led; // Toggle the LED state timeout.attach(&timer_interrupt, TIME); // Set again the timer timeout for next iterations } int main() { timeout.attach(&timer_interrupt, TIME); // Set the timer interrupt service rutine (ISR) and the time for the timeout (in seconds) while(1); // Infinite loop }