use the interrupt the controll the led flash to start
Dependencies: mbed
Fork of InterruptIn_HelloWorld by
Revision 2:e723a11950b5, committed 2014-10-21
- Comitter:
- shiyilei
- Date:
- Tue Oct 21 15:31:21 2014 +0000
- Parent:
- 1:e0f221b58791
- Commit message:
- use the interrupt the controll the led flash to start
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sun Sep 21 18:22:46 2014 +0000 +++ b/main.cpp Tue Oct 21 15:31:21 2014 +0000 @@ -1,17 +1,32 @@ +/******************************************************************** +*file name: key controlled led starting +*Creator:JacobShi +*Time:2014/10/20 +* Description: use the interrupt the controll the led flash to start +*********************************************************************/ #include "mbed.h" - -InterruptIn button(p5); -DigitalOut led(LED1); -DigitalOut flash(LED4); - -void flip() { - led = !led; + +DigitalOut myled(LED1); +InterruptIn mykey(p11); +int enable=0; +void key_process(void) +{ + if(mykey==1) + enable=1; } - -int main() { - button.rise(&flip); // attach the address of the flip function to the rising edge - while(1) { // wait around, interrupts will interrupt this! - flash = !flash; - wait(0.25); +int main(void) +{ + mykey.rise(&key_process); + myled=0; + while(1) + { + if(enable) + { + myled=1; + wait(0.5); + myled=0; + wait(0.5); + } + } -} \ No newline at end of file +}