Rob Toulson / Mbed 2 deprecated PE_09-09_TickerDemo

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 /* Program Example 9.9: Simple demo of "Ticker". Replicates behaviour of first
00002 led flashing program.   
00003                                                                             */
00004 #include "mbed.h"
00005 void led_switch(void);
00006 Ticker time_up;                         //define a Ticker, with name “time_up”
00007 DigitalOut myled(LED1);
00008 
00009 void led_switch(){                      //the function that Ticker will call
00010     myled=!myled;       
00011 }
00012 
00013 int main(){
00014     time_up.attach(&led_switch, 0.2);             //initialises the ticker 
00015     while(1){        //sit in a loop doing nothing, waiting for Ticker interrupt
00016     }
00017 }
00018