El-POM1001 / Mbed 2 deprecated LAB03_Oppgave2

Dependencies:   mbed

Revision:
0:c7377fa95fab
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Oct 15 15:54:42 2015 +0000
@@ -0,0 +1,44 @@
+#include "mbed.h"
+
+InterruptIn SW7(PB_3);
+InterruptIn SW6(PA_10);
+
+Timer timer;
+
+void startKlokke();
+void stoppKlokke();
+void print();
+
+int main() 
+{    
+    
+    printf("Velkommen\n");
+
+    SW7.fall(&startKlokke);
+    SW6.fall(&stoppKlokke);
+
+    while(1) 
+    {
+        
+    }
+    
+}
+void startKlokke()
+{
+   timer.reset();
+   timer.start();        
+}
+    
+void stoppKlokke()
+{
+    timer.stop();
+    print();   
+}
+
+void print()
+{
+    float tidSek=timer.read();
+    float hastighet = (5/tidSek)*3.6;
+    
+    printf("Hastighet %.2f Km\\t\r\n", hastighet); 
+}
\ No newline at end of file