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.
Diff: main.cpp
- Revision:
- 2:aa4afe9a928c
- Parent:
- 0:402d16a0d4dd
- Child:
- 4:2afaac57dc82
--- a/main.cpp Fri Apr 21 16:12:38 2017 +0000 +++ b/main.cpp Fri Jul 07 07:08:20 2017 -0600 @@ -1,46 +1,45 @@ -#include "mbed.h" - -InterruptIn event(USER_BUTTON); -DigitalOut myled(LED1); - -int go_to_sleep = 0; - -void pressed() -{ - printf("Button pressed\n"); - go_to_sleep = go_to_sleep + 1; - if (go_to_sleep > 3) go_to_sleep = 0; - -} - -int main() -{ - int i = 0; - - printf("\nPress Button to enter/exit sleep & deepsleep\n"); - - event.fall(&pressed); - - while (1) { - - if ((go_to_sleep == 0) || (go_to_sleep == 2)) { - printf("%d: Running\n", i); - myled = !myled; - wait(1.0); - } - - if (go_to_sleep == 1) { - myled = 0; - printf("%d: Entering sleep (press user button to resume)\n", i); - sleep(); - } - - if (go_to_sleep == 3) { - myled = 0; - printf("%d: Entering deepsleep (press user button to resume)\n", i); - deepsleep(); - } - - i++; - } -} +#include "mbed.h" + +#define USER_BUTTON PA_0 +InterruptIn event(USER_BUTTON); +DigitalOut myled(LED2); + +int go_to_sleep = 0; + +void pressed() { + printf("Button pressed\n"); + go_to_sleep = go_to_sleep + 1; + if (go_to_sleep > 3) go_to_sleep = 0; + +} + +int main() { + int i = 0; + + printf("\nPress Button to enter/exit sleep & deepsleep\n"); + + event.fall(&pressed); + + while (1) { + + if ((go_to_sleep == 0) || (go_to_sleep == 2)) { + printf("%d: Running\n", i); + myled = !myled; + wait(1.0); + } + + if (go_to_sleep == 1) { + myled = 0; + printf("%d: Entering sleep (press user button to resume)\n", i); + sleep(); + } + + if (go_to_sleep == 3) { + myled = 0; + printf("%d: Entering deepsleep (press user button to resume)\n", i); + deepsleep(); + } + + i++; + } +}