Esercitazione5_8

Dependencies:   mbed

Committer:
MDevolution
Date:
Mon Oct 31 11:12:10 2016 +0000
Revision:
0:8705ea543a5a
Esercitazione5_8

Who changed what in which revision?

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