Mapeamento de pista

Dependencies:   mbed

Revision:
0:c6afbc8aadcb
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Sun Sep 06 01:04:42 2020 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+
+InterruptIn interrupt_right(p9);
+InterruptIn interrupt_left(p10);
+
+DigitalIn line_right(p13);
+DigitalIn line_left(p14);
+
+
+int i = 0;
+int LL;
+int LR;
+float perimetro_roda_tick = (2*3.14*16)/(12*10);
+int giro_right = 0;
+int giro_left = 0;
+float mapa[50][2];
+
+void conta_giro_right()
+{
+    giro_right++;
+}
+
+void conta_giro_left()
+{
+    giro_left++;
+}
+
+void mapeamento()
+{
+    mapa[i][0] = giro_left*perimetro_roda_tick;
+    mapa[i][1] = giro_right*perimetro_roda_tick;  
+    if (LL == 1)
+            i++;
+    giro_right = 0;
+    giro_left = 0; 
+}
+
+
+int main() 
+{
+    interrupt_right.rise(&conta_giro_right);
+    interrupt_left.rise(&conta_giro_left);   
+    while(1) 
+    {
+        LR = line_right.read();
+        LL = line_left.read();
+        if (LR == 1 || LL == 1)
+            mapeamento();   
+    }
+}