Push and hold button to start timer. Release button to print time that the button was held for.

Dependencies:   mbed

Fork of Timer_HelloWorld by mbed official

Revision:
2:1e6dc5131b1b
Parent:
1:272adee7c4ac
--- a/main.cpp	Tue Jan 07 00:24:41 2014 +0000
+++ b/main.cpp	Tue Jan 07 01:16:10 2014 +0000
@@ -1,20 +1,26 @@
 #include "mbed.h"
  
 DigitalIn button1(PTC3); //button for KL46Z
+DigitalOut led1(LED1);
 Timer t;
 
 bool pushed = false;
  
 int main() {
+    led1 =1;
+    
+    printf("Time Ready, use button SW1 to start.\r\n");
     while(true) {
         if(!button1 && !pushed) {
             t.start();
-            printf("Timer Started\r\n");
+            led1 = 0;
+            printf("Timer Started!\r\n");
             pushed = true;
         }
         else if(button1 && pushed) {
             t.stop();
-            printf("The time taken was %f seconds\r\n", t.read());
+            led1 = 1;
+            printf("The time taken was %f seconds.\r\n", t.read());
             t.reset();
             pushed = false;
         }