Blink using Ticker object

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 Ticker toggle_led_ticker;
00004 
00005 DigitalOut led1(LED1);
00006 
00007 void toggle_led() {
00008     led1 = !led1;
00009 }
00010 
00011 int main() {
00012     // Init the ticker with the address of the function (toggle_led) to be attached and the interval (100 ms)
00013     toggle_led_ticker.attach(&toggle_led, 0.1);
00014     while (true) {
00015         // Do other things...
00016     }
00017 }