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 0:af93f2c6ce66, committed 2021-11-11
- Comitter:
- cspista
- Date:
- Thu Nov 11 14:45:44 2021 +0000
- Commit message:
- Final version
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 |
diff -r 000000000000 -r af93f2c6ce66 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Nov 11 14:45:44 2021 +0000 @@ -0,0 +1,29 @@ +/* Demonstrates Timeout, by triggering an event + * a fixed duration after a button press. + */ +#include "mbed.h" +Timeout wecker; //create a Timeout, and name it "Response" +DigitalIn button(BUTTON1); +DigitalOut led(LED1); //blinks with main while(1) loop +volatile int state = 0; + +void noblink() //this function is called at the end of the Timeout +{ + state = 0; // Stop blinking +} + +int main() { + while(1) { + if(button==0) { + wecker.attach(&noblink,2.0); //attach noblink function to Response + //Timeout, to occur after 2 seconds + state = 1; // Start binking LED + } + if(state) { + led=!led; + wait(0.2); + } else { + led = 0; + } + } +}
diff -r 000000000000 -r af93f2c6ce66 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Thu Nov 11 14:45:44 2021 +0000 @@ -0,0 +1,1 @@ +https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400 \ No newline at end of file