Dependencies:   mbed

Revision:
0:d266ed1f3d53
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed Jul 04 11:18:08 2012 +0000
@@ -0,0 +1,45 @@
+#include "mbed.h"
+
+Serial pc(USBTX, USBRX); // tx, rx
+Timer t;
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+DigitalOut start(p5);
+InterruptIn stop(p6);
+DigitalIn counter_start(p7);
+
+void counter();
+
+int main() {
+    
+    start   =   0;
+    pc.baud(921600);
+    
+    led1 = 1;  led2 = 1;  led3 = 1;  led4 = 1;
+    wait(0.5);    led4    =   0;
+    wait(0.5);    led3    =   0;
+    wait(0.5);    led2    =   0;
+    wait(0.5);    led1    =   0;
+    wait(0.5);
+    led1 = 1;  led2 = 1;  led3 = 1;  led4 = 1;
+    
+    stop.rise(&counter);
+    
+    pc.printf("Push button!\r\n");
+    while( counter_start==0 ){}
+    pc.printf("Counter starts!!\r\n");
+    start   =   1;
+    t.start();
+            
+    while( start==1 ){}
+
+    printf("The time was taken %f seconds\r\n", t.read());
+
+}
+
+void counter() {
+    t.stop();
+    start   =   0;
+}
\ No newline at end of file