Mike EI2I
/
BouttonD3Interrupt
Gestion d'un interrupte avec le button
main.cpp@0:d26e8921753c, 2015-03-11 (annotated)
- Committer:
- Kemix
- Date:
- Wed Mar 11 08:38:23 2015 +0000
- Revision:
- 0:d26e8921753c
- Child:
- 1:034543cd3064
Le bouton en D3 permet d'activer ou d?sactiver le clignotement d'une led
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
Kemix | 0:d26e8921753c | 1 | #include "mbed.h" |
Kemix | 0:d26e8921753c | 2 | |
Kemix | 0:d26e8921753c | 3 | int flag = 0; |
Kemix | 0:d26e8921753c | 4 | |
Kemix | 0:d26e8921753c | 5 | void truc(void){ |
Kemix | 0:d26e8921753c | 6 | flag = !flag; |
Kemix | 0:d26e8921753c | 7 | } |
Kemix | 0:d26e8921753c | 8 | |
Kemix | 0:d26e8921753c | 9 | int main(void){ |
Kemix | 0:d26e8921753c | 10 | DigitalOut led(LED1); |
Kemix | 0:d26e8921753c | 11 | led = 1; |
Kemix | 0:d26e8921753c | 12 | InterruptIn btn(D3); |
Kemix | 0:d26e8921753c | 13 | |
Kemix | 0:d26e8921753c | 14 | btn.rise(truc); |
Kemix | 0:d26e8921753c | 15 | while(1){ |
Kemix | 0:d26e8921753c | 16 | if(flag != 0){ |
Kemix | 0:d26e8921753c | 17 | led = !led; |
Kemix | 0:d26e8921753c | 18 | wait(0.15); |
Kemix | 0:d26e8921753c | 19 | } |
Kemix | 0:d26e8921753c | 20 | } |
Kemix | 0:d26e8921753c | 21 | } |