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.
main.cpp
00001 /*Program Example 9.6: Demonstrates Timeout, by triggering an event a fixed duration after a button press. */ 00002 00003 #include "mbed.h" 00004 Timeout Response; //create a Timeout, and name it "Response" 00005 DigitalIn button (p5); 00006 DigitalOut led1(LED1); 00007 DigitalOut led2(LED2); 00008 DigitalOut led3(LED3); 00009 00010 void blink() { //this function is called at the end of the Timeout 00011 led2 = 1; 00012 wait(0.5); 00013 led2=0; 00014 } 00015 00016 int main() { 00017 while(1) { 00018 if(button==1){ 00019 Response.attach(&blink,2.0); // attach blink function to Response Timeout, 00020 //to occur after 2 seconds 00021 led3=1; //shows button has been pressed 00022 } 00023 else { 00024 led3=0; 00025 } 00026 led1=!led1; 00027 wait(0.2); 00028 } 00029 } 00030
Generated on Fri Jul 22 2022 09:01:57 by
1.7.2