KNTL

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
hisyamfs
Date:
Wed May 01 11:59:30 2019 +0000
Commit message:
jancuk;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 7850f26e290c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Wed May 01 11:59:30 2019 +0000
@@ -0,0 +1,31 @@
+#include "mbed.h"
+ 
+InterruptIn line(PA_0);
+Timer timer;
+volatile float dur = 0.0f;
+int printed = 0;
+
+void start() {
+    timer.reset();
+    timer.start();
+}
+
+void end() {
+    timer.stop();
+    dur = timer.read();   
+}
+
+int main() {
+    line.fall(&start);
+    line.rise(&end);
+    while (1) {
+        if (!printed) {
+            printf("%.2f\n", dur);
+            printed = 1;
+        }
+        else {
+            printed = 0;
+        }
+    } 
+}
+ 
\ No newline at end of file
diff -r 000000000000 -r 7850f26e290c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed May 01 11:59:30 2019 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file