Ticker

Dependencies:   mbed

Committer:
Mattinico
Date:
Sun Nov 06 12:42:56 2016 +0000
Revision:
0:c25c01018413
k

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mattinico 0:c25c01018413 1 /* Program Example 8: Simple demo of "Ticker". Replicates behavior of first
Mattinico 0:c25c01018413 2 led flashing program.
Mattinico 0:c25c01018413 3 */
Mattinico 0:c25c01018413 4 #include "mbed.h"
Mattinico 0:c25c01018413 5 void led_switch(void);
Mattinico 0:c25c01018413 6 Ticker time_up; //define a Ticker, with name “time_up”//TIC TIC TIC TIC cosa riipetuta in un loop
Mattinico 0:c25c01018413 7 DigitalOut myled(D3);
Mattinico 0:c25c01018413 8 void led_switch() //the function that Ticker will call
Mattinico 0:c25c01018413 9 {
Mattinico 0:c25c01018413 10 myled=!myled;
Mattinico 0:c25c01018413 11 }
Mattinico 0:c25c01018413 12 int main()
Mattinico 0:c25c01018413 13 {
Mattinico 0:c25c01018413 14 time_up.attach(&led_switch, 0.5); //initializes the ticker
Mattinico 0:c25c01018413 15 while(1) { //sit in a loop doing nothing, waiting for Ticker interrupt
Mattinico 0:c25c01018413 16 }
Mattinico 0:c25c01018413 17 }