AVGG

Dependencies:   mbed

Fork of 7_7Boboobooo by 譯文 張

Revision:
15:7f21c08be164
Parent:
14:8b17b298b4dd
--- a/main.cpp	Thu Jul 10 14:52:32 2014 +0000
+++ b/main.cpp	Thu Jul 10 16:38:27 2014 +0000
@@ -27,7 +27,7 @@
     int t = 0;
     double last = 0.0;
     double avgg = middle,last_avgg = middle, next_avgg = middle;
-    double v = 0.4;
+    double v = 0.5;
     
     //char psudo_line[128];
     
@@ -90,8 +90,8 @@
                 turn = 0.026;
             else 
                 turn = 0.054;
-            /*else 
-                turn = middle;*/
+            //else 
+              //  turn = middle;
             flag = 0;
             
         } else if (black_centerL == 118 && black_centerR != 10){//no left line turn right flag = 1
@@ -158,23 +158,23 @@
         times++;
         t++;
 
-        if(times == 2){
+        if(times == 5){
             
             avg = last_turn / times;
             if(avg < 0.042 && avg > 0.034){
-                v = 0.4;
+                v = 0.5;
             }
             else{
                 v = 0.18;
             }
             MotorA.rotate(v);
             MotorB.rotate(v);
-            servo.set_angle((avg*7 + next_avgg)/8);
+            servo.set_angle((avg*6 + next_avgg)/7);
             //servo.set_angle(avg);
             times = last_turn = 0;
             
         }
-        if(t == 500){
+        if(t == 1000){
             last_avgg = avgg;
             avgg = last / t;
             next_avgg = 2*avgg -last_avgg;