Timeout ripetitivi

Dependencies:   mbed

Committer:
Mattinico
Date:
Sun Nov 06 12:42:16 2016 +0000
Revision:
0:6550097e4ad1
k

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Mattinico 0:6550097e4ad1 1 #include "mbed.h"
Mattinico 0:6550097e4ad1 2 Timeout to1;
Mattinico 0:6550097e4ad1 3 DigitalOut myled(D3);
Mattinico 0:6550097e4ad1 4 DigitalIn BlueButton(USER_BUTTON);
Mattinico 0:6550097e4ad1 5 #define DLYFlash 0.2
Mattinico 0:6550097e4ad1 6 bool ONOFF_Flashing = false;
Mattinico 0:6550097e4ad1 7 void IntFlash(void);
Mattinico 0:6550097e4ad1 8
Mattinico 0:6550097e4ad1 9 int main()
Mattinico 0:6550097e4ad1 10 {
Mattinico 0:6550097e4ad1 11 to1.attach(&IntFlash, DLYFlash);
Mattinico 0:6550097e4ad1 12 while(1) {
Mattinico 0:6550097e4ad1 13 if (BlueButton == 0)
Mattinico 0:6550097e4ad1 14 ONOFF_Flashing = true;
Mattinico 0:6550097e4ad1 15 else
Mattinico 0:6550097e4ad1 16 ONOFF_Flashing = false;
Mattinico 0:6550097e4ad1 17 }
Mattinico 0:6550097e4ad1 18 }
Mattinico 0:6550097e4ad1 19
Mattinico 0:6550097e4ad1 20 void IntFlash(void)
Mattinico 0:6550097e4ad1 21 {
Mattinico 0:6550097e4ad1 22 if (ONOFF_Flashing == true) {
Mattinico 0:6550097e4ad1 23 myled = !myled;
Mattinico 0:6550097e4ad1 24 }
Mattinico 0:6550097e4ad1 25 else {
Mattinico 0:6550097e4ad1 26 myled = 0;
Mattinico 0:6550097e4ad1 27 }
Mattinico 0:6550097e4ad1 28 to1.detach();
Mattinico 0:6550097e4ad1 29 to1.attach(&IntFlash, DLYFlash); // this line reload Interrupt
Mattinico 0:6550097e4ad1 30 }