Timeout ripetitivi

Dependencies:   mbed

main.cpp

Committer:
Mattinico
Date:
2016-11-06
Revision:
0:6550097e4ad1

File content as of revision 0:6550097e4ad1:

 #include "mbed.h"
 Timeout to1;
 DigitalOut myled(D3);
 DigitalIn BlueButton(USER_BUTTON);
 #define DLYFlash 0.2
 bool ONOFF_Flashing = false;
 void IntFlash(void);

 int main()
 {
     to1.attach(&IntFlash, DLYFlash);
     while(1) {
         if (BlueButton == 0)
         ONOFF_Flashing = true;
         else
         ONOFF_Flashing = false;
     }
 }

 void IntFlash(void)
 {
     if (ONOFF_Flashing == true) {
     myled = !myled;
 } 
 else {
    myled = 0;
 }
 to1.detach();
 to1.attach(&IntFlash, DLYFlash); // this line reload Interrupt
 }