Mapeamento de pista

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
raylaneleite
Date:
Sun Sep 06 01:04:42 2020 +0000
Commit message:
encoder

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 c6afbc8aadcb main.cpp
--- /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();   
+    }
+}
diff -r 000000000000 -r c6afbc8aadcb mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sun Sep 06 01:04:42 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file