Prenden los leds en forma intermitente mediante timers e interrupciones sin hacer uso del programa principal

Dependencies:   mbed

Committer:
rcortes
Date:
Mon Mar 24 19:13:30 2014 +0000
Revision:
0:51f1b3f465c9
Prenden los leds en forma intermitente mediante timers e interrupciones; sin hacer uso del programa principal

Who changed what in which revision?

UserRevisionLine numberNew contents of line
rcortes 0:51f1b3f465c9 1 //Prenden los leds en forma intermitente mediante timers e interrupciones
rcortes 0:51f1b3f465c9 2 //Sin hacer uso del programa principal
rcortes 0:51f1b3f465c9 3 #include "mbed.h"
rcortes 0:51f1b3f465c9 4 Ticker tick_V,tick_R;
rcortes 0:51f1b3f465c9 5 DigitalOut rojo(LED_RED);
rcortes 0:51f1b3f465c9 6 DigitalOut verde(LED_GREEN);
rcortes 0:51f1b3f465c9 7 void flip_V()
rcortes 0:51f1b3f465c9 8 {
rcortes 0:51f1b3f465c9 9 verde = !verde;
rcortes 0:51f1b3f465c9 10 }
rcortes 0:51f1b3f465c9 11 void flip_R()
rcortes 0:51f1b3f465c9 12 {
rcortes 0:51f1b3f465c9 13 rojo = !rojo;
rcortes 0:51f1b3f465c9 14 }
rcortes 0:51f1b3f465c9 15 int main()
rcortes 0:51f1b3f465c9 16 {
rcortes 0:51f1b3f465c9 17 tick_V.attach(&flip_V, 0.5); // setup ticker to call flip led_Green after 0.5 seconds
rcortes 0:51f1b3f465c9 18 tick_R.attach(&flip_R, 0.25); // setup ticker to call flip led_Red after 0.25 seconds
rcortes 0:51f1b3f465c9 19 // spin in a main loop.
rcortes 0:51f1b3f465c9 20 while (true) {
rcortes 0:51f1b3f465c9 21 }
rcortes 0:51f1b3f465c9 22 }