Valentin Dubois
/
Allumage_LED
Allume/éteint la LED quand on appuie sur le bouton
Revision 0:c72f09731dd4, committed 2014-05-15
- Comitter:
- valdub
- Date:
- Thu May 15 08:23:02 2014 +0000
- Commit message:
- Program published
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu May 15 08:23:02 2014 +0000 @@ -0,0 +1,26 @@ +#include "mbed.h" + +DigitalOut myled(LED1); +InterruptIn button(USER_BUTTON); +Timer debounce; + +int i=0; + +void toggle() +{ + if (debounce.read_ms() > 100) { + i = !i; } + debounce.reset(); +} + +int main() +{ + myled = 0; + button.rise( &toggle ); + debounce.start(); + + while (1) + { + myled = (i == true) ?1 :0; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu May 15 08:23:02 2014 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/6473597d706e \ No newline at end of file