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.
Dependencies: mbed
Fork of Ticker_3 by
Diff: main.cpp
- Revision:
- 1:3b84da6d133f
- Parent:
- 0:0ba4641adab9
- Child:
- 2:e94dce9a7464
--- a/main.cpp Fri Oct 13 02:39:35 2017 +0000
+++ b/main.cpp Fri Oct 13 03:25:04 2017 +0000
@@ -1,21 +1,42 @@
-// Flash an LED while waiting for events
+// Blink until timeout.
#include "mbed.h"
-InterruptIn event(D5);
-DigitalOut ledr(D13);
-DigitalOut ledg(D11);
+Timeout timeout;
+DigitalOut led(D13);
-void trigger() {
- printf("triggered!\n");
- ledg =! ledg;
-
+int secFlag = 1;
+int secTic=0;
+
+void attimeout() {
+ secFlag=1;
+
+
}
int main() {
- event.rise(&trigger);
+
while(1) {
- ledr =! ledr;
- wait(0.25);
+ if(secFlag) //1s
+ {
+ secFlag=0;
+ timeout.attach(&attimeout, 1);
+
+ secTic++;
+ }
+
+ if(secTic==1)
+ { led =0;
+ wait(0.5);
+ led =1;
+ wait(0.5);
+ }
+
+ if(secTic==10)
+ { led =0;
+ wait(0.5);
+ led =1;
+ wait(0.5);
+ }
}
}
