init

Dependencies:   mbed pixy

Revision:
0:98d2bcd7ae29
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Jun 09 23:20:19 2017 +0000
@@ -0,0 +1,73 @@
+#include "mbed.h"
+#include "fct.h"
+#include "Pixy.h"
+#include "PixyLink.h"
+
+#define V_max 25
+#define V_recherche 25
+#define K 0.1
+DigitalOut cs(p13);
+DigitalIn bp(p14);
+Serial pc (USBTX,USBRX);
+
+
+
+int main()
+{
+    bp.mode(PullUp);
+    MotG.period(PERIOD);
+    MotD.period(PERIOD);
+    Vitmoteur(0.0,0.0);
+    Pixy pixy= Pixy(p28,p27);
+    pixy.setSerialOutput(&pc);
+    int j=0;
+    uint16_t blocks;
+    float taille,errorX;
+    pc.printf("alive");
+    
+
+    while(1) {
+        init();// recupere valeurs capteurs ligne blanche
+        pc.printf("capt1= %d capt2= %d\n\r",captL1,captL3);
+        wait(0.5);
+        if(captL1==0 && captL3==0)
+        {
+            Vitmoteur(20,20);
+            }
+        else{
+            Vitmoteur(-20,-20);
+            wait(5);
+            }
+            
+}
+}
+//printf("ok");
+
+//MotD.pulsewidth(0.5*PERIOD);
+//MotG.pulsewidth(0.5*PERIOD);
+//MotD.pulsewidth(0.00005);
+
+    /* blocks=pixy.getBlocks();
+     if(blocks) {
+         taille = pixy.blocks[j].width*pixy.blocks[j].height;
+         errorX=(160-pixy.blocks[j].x);
+         Vitmoteur(V_max-K*errorX,V_max+K*errorX);
+         //pc.printf("ok");
+         //Vitmoteur(1,-1);
+     } else {
+         //pc.printf("beug");
+         Vitmoteur(0.0,0.0);
+     }
+
+     if(errorX>V_max) {
+         errorX=V_max;
+     }
+     if(errorX<-V_max) {
+         errorX=-V_max;
+     }
+     Vitmoteur(V_max-K*errorX,V_max+K*errorX);
+
+    }*/
+
+
+