Yeongsoo Kim / Mbed 2 deprecated Mecha_Lane_Sensor

Dependencies:   mbed

Revision:
0:a0e9db1628f1
diff -r 000000000000 -r a0e9db1628f1 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Nov 16 22:37:13 2020 +0000
@@ -0,0 +1,40 @@
+#include "mbed.h"
+#include "LaneSensor.h"
+
+//To plot with usb, set as below.
+Serial pc(USBTX,USBRX); // Tx, Rx Pin
+
+//Set each gpio to see the output of the hall sensor as a led
+LaneSensor laneSensor(p11,p12,p13,p14,p15,p16,p17);
+
+//Interrupt is generated every 1ms and count is increased by 1
+unsigned int uiFlag_1ms = 0;
+unsigned int uiFlag_50ms = 0;
+
+void counter_1ms ()
+{
+    uiFlag_1ms++;
+    uiFlag_50ms++;
+}
+
+int main()
+{
+    wait(1);
+
+    ////Set the 1ms thicker.
+    Ticker ticker_1ms;
+    ticker_1ms.attach(&counter_1ms, 0.001);
+    
+
+    while(1) 
+    {
+        // Every 50 ms,
+        if(uiFlag_50ms >= 50) {
+            uiFlag_50ms = 0;
+            
+            int data = laneSensor.getData();
+            float error = laneSensor.getError();
+            pc.printf ("data: %d, error: %f \r\n", data, error);
+        }
+    }
+}
\ No newline at end of file