Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 1:e470129442d8, committed 2020-09-16
- Comitter:
- pierreprovent
- Date:
- Wed Sep 16 08:49:28 2020 +0000
- Parent:
- 0:918fdb31e2ce
- Commit message:
- Programme de base pour cours Cnam ELE118
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 918fdb31e2ce -r e470129442d8 main.cpp --- a/main.cpp Tue Sep 15 11:24:56 2020 +0000 +++ b/main.cpp Wed Sep 16 08:49:28 2020 +0000 @@ -1,12 +1,14 @@ #include "mbed.h" +DigitalIn mybutton(USER_BUTTON); DigitalOut myled(LED1); -int main() { +int main() +{ while(1) { - myled = 1; // LED is ON - wait(0.2); // 200 ms - myled = 0; // LED is OFF - wait(1.0); // 1 sec + if (mybutton == 0) { // Button is pressed + myled = !myled; // Toggle the LED state + wait(0.2); // 200 ms + } } }