7Robot_Freescale / Mbed 2 deprecated freescal_cup_k22f

Dependencies:   mbed freescal_cup_k22f

Dependents:   freescal_cup_k22f

Revision:
21:9430357e777c
Parent:
20:24ebe046ebe9
Child:
22:b5a3688e144b
diff -r 24ebe046ebe9 -r 9430357e777c source/main.cpp
--- a/source/main.cpp	Sat Jan 17 16:51:33 2015 +0000
+++ b/source/main.cpp	Sat Jan 17 17:45:52 2015 +0000
@@ -19,9 +19,11 @@
  // Initialisation
  
     int indexMin=0;   
-    int indexMax=128;
+    int indexMax=127;
     int compteur_uart=0;
-    int max_detect=indexMin;
+    int max_detect1=indexMin;
+    int max_detect2=indexMin;
+    int max_detect=(max_detect1+max_detect2)/2;
     float Kp_servo = 0;
     uart.baud(115200); 
     init_led();
@@ -33,7 +35,7 @@
     while(1){
         
         readline();
-        //passebas(12);
+        passebas(12);
         //derivation();
         //passebas(4); 
            
@@ -59,13 +61,18 @@
         compteur_uart =compteur_uart+1;  
         }
         
-        for (int j=indexMin; j<indexMax; j++)
+        for (int j=indexMin; j<=indexMax; j++)
         {
             if (pixel1[j]>pixel1[max_detect])
             {
-                max_detect=j;
+                max_detect1=j;
             }
-        }    
+            if (pixel1[j]>pixel2[max_detect])
+            {
+                max_detect2=j;
+            }    
+        }  
+        max_detect=(max_detect1+max_detect2)/2; 
         // Réduction proportionelle de la vitesse moteur si l'angle du servo augmente
         if (max_detect>64)
         {