Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
Mattinico
Date:
Sun Nov 06 12:41:56 2016 +0000
Commit message:
k

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 024eaeca4fce main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Nov 06 12:41:56 2016 +0000
@@ -0,0 +1,30 @@
+ /*Program Example 5: 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 (PC_13);
+ DigitalOut led1(LED1);
+ DigitalOut led2(D5);
+ DigitalOut led3(D3);
+ void blink() //this function is called at the end of the Timeout
+ {
+     led2 = 1;
+     wait(1);
+     led2=0;
+ }
+ int main()
+ {
+     while(1) {
+         if(button==0) {
+             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);
+     }
+ }
diff -r 000000000000 -r 024eaeca4fce mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Nov 06 12:41:56 2016 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/9bcdf88f62b0
\ No newline at end of file