LEDs and user button example.
Dependencies: mbed
Revision 1:8932d9db4aaf, committed 2017-09-26
- Comitter:
- bcostm
- Date:
- Tue Sep 26 12:55:12 2017 +0000
- Parent:
- 0:b385f231a65a
- Commit message:
- Add mbed library v151
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 |
--- a/main.cpp Wed May 17 16:43:49 2017 +0200 +++ b/main.cpp Tue Sep 26 12:55:12 2017 +0000 @@ -1,27 +1,29 @@ #include "mbed.h" - + DigitalOut myled1(LED1); DigitalOut myled2(LED2); DigitalOut myled3(LED3); - + InterruptIn mybutton(USER_BUTTON); - + double tempo = 0.2; //time to wait - -void changetempo() { + +void changetempo() +{ if(tempo == 0.2) // If leds have low frequency tempo = 0.1; // Set the fast frequency else // If les have fast frequency tempo = 0.2; // Set the low frequency } - -int main() { + +int main() +{ myled1 = 0; //LED1 is OFF myled2 = 0; //LED2 is OFF myled3 = 0; //LED3 is OFF - + mybutton.fall(&changetempo); //Interrupt to change tempo - + while(1) { myled1 = 1; // LED2 is ON wait(tempo); // wait tempo @@ -34,4 +36,3 @@ myled3 = 0; // LED3 is OFF } } - \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Sep 26 12:55:12 2017 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/675da3299148 \ No newline at end of file