Mike EI2I
/
BouttonD3Interrupt
Gestion d'un interrupte avec le button
main.cpp@1:034543cd3064, 2015-03-11 (annotated)
- Committer:
- Kemix
- Date:
- Wed Mar 11 09:04:44 2015 +0000
- Revision:
- 1:034543cd3064
- Parent:
- 0:d26e8921753c
en mode mieux
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 | InterruptIn btn(D3); |
Kemix | 1:034543cd3064 | 12 | led = 0; |
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 | 1:034543cd3064 | 19 | }else{ |
Kemix | 1:034543cd3064 | 20 | led = 0; |
Kemix | 0:d26e8921753c | 21 | } |
Kemix | 0:d26e8921753c | 22 | } |
Kemix | 0:d26e8921753c | 23 | } |