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:a4095d77cfff, committed 2013-05-24
- Comitter:
- robt
- Date:
- Fri May 24 21:48:28 2013 +0000
- Commit message:
- by Rob Toulson and Tim Wilmshurst from textbook "Fast and Effective Embedded Systems Design: Applying the ARM mbed"
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 Fri May 24 21:48:28 2013 +0000
@@ -0,0 +1,30 @@
+/*Program Example 9.6: Demonstrates Timeout, by triggering an event a fixed duration after a button press. */
+
+#include "mbed.h"
+Timeout Response; //create a Timeout, and name it "Response"
+DigitalIn button (p5);
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+
+void blink() { //this function is called at the end of the Timeout
+ led2 = 1;
+ wait(0.5);
+ led2=0;
+}
+
+int main() {
+ while(1) {
+ if(button==1){
+ Response.attach(&blink,2.0); // attach blink function to Response Timeout,
+ //to occur after 2 seconds
+ led3=1; //shows button has been pressed
+ }
+ else {
+ led3=0;
+ }
+ led1=!led1;
+ wait(0.2);
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Fri May 24 21:48:28 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17 \ No newline at end of file