aa

Dependencies:   mbed

Revision:
44:2aff0da5ebdb
Parent:
43:1bb4fbe7d4c6
Child:
45:0cf48a0605cd
--- a/System/Process/Process.cpp	Sat Nov 09 14:50:14 2019 +0000
+++ b/System/Process/Process.cpp	Sun Nov 10 05:51:51 2019 +0000
@@ -1922,110 +1922,114 @@
             cross=0;
             mode=3;
         }
-    } else if(mode==3) { //横ライントレースから縦ライントレースへ
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
+    } 
+    else if(mode==3) { //横ライントレースから縦ライントレースへ
+        motor[TIRE_FR].pwm = 255;
+        motor[TIRE_FR].dir = BRAKE;
         motor[TIRE_FL].pwm = 30;
         motor[TIRE_FL].dir = FOR;
         motor[TIRE_BR].pwm = 30;
         motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
+        motor[TIRE_BL].pwm = 255;
+        motor[TIRE_BL].dir = BRAKE;
         if(g[0]==0) {
             mode=10;
             countss=100000;
         }
-    } else if(mode==10) { //縦ライントレース
+    } 
+    else if(mode==10) { //縦ライントレース
         switch(g[0]) {
             case 98:
-                motor[TIRE_FR].pwm = normal+20;
+                motor[TIRE_FR].pwm = normal+50;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = normal+20;
+                motor[TIRE_FL].pwm = normal+50;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = normal+20;
+                motor[TIRE_BR].pwm = normal+50;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = normal+20;
+                motor[TIRE_BL].pwm = normal+50;
                 motor[TIRE_BL].dir = FOR;
                 mtc=true;
                 if(countss>80000) {
                     cross++;
                     countss=0;
                 }
-                /*
                 if(cross==2){
-                    fast = 30;
-                    normal = 20;
-                    slow = 20;     
-                }
-                */
+                    fast = 10;  
+                    normal = 10; 
+                    slow = 5;
+                }    
+                
                 if(cross==3) {
+                    fast=40;
+                    normal=30;
+                    slow=20;
                     mode=11;
                     countss=0;
                     cross=0;
+                    
                 }
                 break;
-                //+15した
             case 0:
-                motor[TIRE_FR].pwm = fast+20;
+                motor[TIRE_FR].pwm = fast+50;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = fast+20;
+                motor[TIRE_FL].pwm = fast+50;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = fast+20;
+                motor[TIRE_BR].pwm = fast+50;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = fast+20;
+                motor[TIRE_BL].pwm = fast+50;
                 motor[TIRE_BL].dir = FOR;
                 mtc=true;
                 break;
             case 255:
-                motor[TIRE_FR].pwm = fast+20;
+                motor[TIRE_FR].pwm = fast+50;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = slow+20;
+                motor[TIRE_FL].pwm = slow+50;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = slow+20;
+                motor[TIRE_BR].pwm = slow+50;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = fast+20;
+                motor[TIRE_BL].pwm = fast+50;
                 motor[TIRE_BL].dir = FOR;
                 mtc=true;
                 break;
             case 253:
-                motor[TIRE_FR].pwm = slow+20;
+                motor[TIRE_FR].pwm = slow+50;
                 motor[TIRE_FR].dir = BACK;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
                 motor[TIRE_BR].pwm = 0;
                 motor[TIRE_BR].dir = FREE;
-                motor[TIRE_BL].pwm = slow+20;
+                motor[TIRE_BL].pwm = slow+50;
                 motor[TIRE_BL].dir = FOR;
                 mtc=true;
                 break;
             case 254:
-                motor[TIRE_FR].pwm = normal+20;
+                motor[TIRE_FR].pwm = normal+50;
                 motor[TIRE_FR].dir = BACK;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
                 motor[TIRE_BR].pwm = 0;
                 motor[TIRE_BR].dir = FREE;
-                motor[TIRE_BL].pwm = normal+20;
+                motor[TIRE_BL].pwm = normal+50;
                 motor[TIRE_BL].dir = FOR;
                 mtc=true;
                 break;
             case 1:
-                motor[TIRE_FR].pwm = slow+20;
+                motor[TIRE_FR].pwm = slow+50;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = fast+20;
+                motor[TIRE_FL].pwm = fast+50;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = fast+20;
+                motor[TIRE_BR].pwm = fast+50;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = slow+20;
+                motor[TIRE_BL].pwm = slow+50;
                 motor[TIRE_BL].dir = FOR;
                 mtc=true;
                 break;
             case 3:
                 motor[TIRE_FR].pwm = 0;
                 motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = slow+20;
+                motor[TIRE_FL].pwm = slow+50;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = slow+20;
+                motor[TIRE_BR].pwm = slow+50;
                 motor[TIRE_BR].dir = BACK;
                 motor[TIRE_BL].pwm = 0;
                 motor[TIRE_BL].dir = FREE;
@@ -2034,9 +2038,9 @@
             case 2:
                 motor[TIRE_FR].pwm = 0;
                 motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = normal+20;
+                motor[TIRE_FL].pwm = normal+50;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = normal+20;
+                motor[TIRE_BR].pwm = normal+50;
                 motor[TIRE_BR].dir = BACK;
                 motor[TIRE_BL].pwm = 0;
                 motor[TIRE_BL].dir = FREE;
@@ -2049,72 +2053,74 @@
                     mtc=false;
                     break;
                 case 255:
-                    motor[TIRE_BR].pwm += 5;
+                    motor[TIRE_BR].pwm += 3;
                     mtc=false;
                     break;
                 case 253:
-                    motor[TIRE_BR].pwm += 10;
+                    motor[TIRE_BR].pwm += 6;
                     mtc=false;
                     break;
                 case 254:
-                    motor[TIRE_BR].pwm += 20;
+                    motor[TIRE_BR].pwm += 9;
                     motor[TIRE_BL].pwm = 0;
                     mtc=false;
                     break;
                 case 1:
-                    motor[TIRE_BL].pwm += 5;
+                    motor[TIRE_BL].pwm += 3;
                     mtc=false;
                     break;
                 case 3:
-                    motor[TIRE_BL].pwm += 10;
+                    motor[TIRE_BL].pwm += 6;
                     mtc=false;
                     break;
                 case 2:
-                    motor[TIRE_BL].pwm += 20;
+                    motor[TIRE_BL].pwm += 9;
                     motor[TIRE_BR].pwm = 0;
                     mtc=false;
                     break;
             }
         }
-    } else if(mode==11) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
+    } 
+    else if(mode==11) {
+        motor[TIRE_FR].pwm = 25;
+        motor[TIRE_FR].dir = FOR;
         motor[TIRE_FL].pwm = normal;
         motor[TIRE_FL].dir = FOR;
         motor[TIRE_BR].pwm = normal;
         motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(g[2]==0) {
+        motor[TIRE_BL].pwm = 25;
+        motor[TIRE_BL].dir = BACK;
+        if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) {
             countss=0;
             cross=0;
             mode=20;
         }
-    } else if(mode==20) {
+    } 
+    else if(mode==20) {
         solenoid.solenoid4= SOLENOID_ON;
         switch(g[2]) {
             case 98:
-                motor[TIRE_FR].pwm = normal+10;
+                motor[TIRE_FR].pwm = normal+20;
                 motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = normal+10;
+                motor[TIRE_FL].pwm = normal+20;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = normal+10;
+                motor[TIRE_BR].pwm = normal+20;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = normal+10;
+                motor[TIRE_BL].pwm = normal+20;
                 motor[TIRE_BL].dir = BACK;
                 if(countss>30000) {
                     cross++;
                     countss=0;
                 }
                 mtc2=true;
-                //change
-                if(cross==1) {
+                
+                if(YELLOW) {
+                    if(cross==1) {
                     fast=30;
                     normal=20;
                     slow=20;
-                }
-                if(YELLOW) {
-                    if(cross==2) {
+                    }
+                    else if(cross==2) {
                         mode=21;
                         countss=0;
                         cross=0;
@@ -2128,33 +2134,33 @@
                 }
                 break;
             case 0:
-                motor[TIRE_FR].pwm = fast+15;
+                motor[TIRE_FR].pwm = fast+20;
                 motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = fast+15;
+                motor[TIRE_FL].pwm = fast+20;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = fast+15;
+                motor[TIRE_BR].pwm = fast+20;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = fast+15;
+                motor[TIRE_BL].pwm = fast+20;
                 motor[TIRE_BL].dir = BACK;
                 mtc2=true;
                 break;
             case 255:
-                motor[TIRE_FR].pwm = normal+15;
+                motor[TIRE_FR].pwm = normal+20;
                 motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = fast+15;
+                motor[TIRE_FL].pwm = fast+20;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = fast+15;
+                motor[TIRE_BR].pwm = fast+20;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = normal+15;
+                motor[TIRE_BL].pwm = normal+20;
                 motor[TIRE_BL].dir = BACK;
                 mtc2=true;
                 break;
             case 253:
                 motor[TIRE_FR].pwm = 0;
                 motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = slow+15;
+                motor[TIRE_FL].pwm = slow+20;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = slow+15;
+                motor[TIRE_BR].pwm = slow+20;
                 motor[TIRE_BR].dir = BACK;
                 motor[TIRE_BL].pwm = 0;
                 motor[TIRE_BL].dir = FREE;
@@ -2163,44 +2169,44 @@
             case 254:
                 motor[TIRE_FR].pwm = 0;
                 motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = normal+15;
+                motor[TIRE_FL].pwm = normal+20;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = normal+15;
+                motor[TIRE_BR].pwm = normal+20;
                 motor[TIRE_BR].dir = BACK;
                 motor[TIRE_BL].pwm = 0;
                 motor[TIRE_BL].dir = FREE;
                 mtc2=true;
                 break;
             case 1:
-                motor[TIRE_FR].pwm = fast+15;
+                motor[TIRE_FR].pwm = fast+20;
                 motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = slow+15;
+                motor[TIRE_FL].pwm = slow+20;
                 motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = slow+15;
+                motor[TIRE_BR].pwm = slow+20;
                 motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = fast+15;
+                motor[TIRE_BL].pwm = fast+20;
                 motor[TIRE_BL].dir = BACK;
                 mtc2=true;
                 break;
             case 3:
-                motor[TIRE_FR].pwm = slow+15;
+                motor[TIRE_FR].pwm = slow+20;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
                 motor[TIRE_BR].pwm = 0;
                 motor[TIRE_BR].dir = FREE;
-                motor[TIRE_BL].pwm = slow+15;
+                motor[TIRE_BL].pwm = slow+20;
                 motor[TIRE_BL].dir = BACK;
                 mtc2=true;
                 break;
             case 2:
-                motor[TIRE_FR].pwm = normal+15;
+                motor[TIRE_FR].pwm = normal+20;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
                 motor[TIRE_BR].pwm = 0;
                 motor[TIRE_BR].dir = FREE;
-                motor[TIRE_BL].pwm = normal+15;
+                motor[TIRE_BL].pwm = normal+20;
                 motor[TIRE_BL].dir = BACK;
                 mtc2=true;
                 break;
@@ -2219,7 +2225,7 @@
                     mtc2=false;
                     break;
                 case 254:
-                    motor[TIRE_BL].pwm += 20;
+                    motor[TIRE_BL].pwm += 15;
                     motor[TIRE_FL].pwm = 0;
                     mtc2=false;
                     break;
@@ -2232,7 +2238,7 @@
                     mtc2=false;
                     break;
                 case 2:
-                    motor[TIRE_FL].pwm += 20;
+                    motor[TIRE_FL].pwm += 15;
                     motor[TIRE_BL].pwm = 0;
                     mtc2=false;
                     break;
@@ -2256,7 +2262,8 @@
                 normal=40;
                 slow=20;
             }
-        } else if(mode==22) {
+        } 
+        else if(mode==22) {
             if(g[4]==3||g[4]==2) {
                 motor[TIRE_FR].pwm = 30;
                 motor[TIRE_FR].dir = FOR;
@@ -2368,7 +2375,8 @@
                 mode=23;
                 countss=0;
             }
-        } else if(mode==23) {
+        } 
+        else if(mode==23) {
             switch(g[4]) {
                 case 98:
                     motor[TIRE_FR].pwm = fast-5;
@@ -2466,7 +2474,6 @@
                 motor[MOTOR_0].dir = BRAKE;
             }
             if(g[1]==98) {
-                //Change
                 fast=20;
                 normal=15;
                 slow=10;
@@ -2486,11 +2493,13 @@
                 normal=40;
                 slow=20;
             }
-        } else if(mode==24) {
+        } 
+        else if(mode==24) {
             if(DOLS==true||UPLS==true) {
                 motor[MOTOR_0].pwm = 200;
                 motor[MOTOR_0].dir = BRAKE;
-            } else {
+            } 
+            else {
                 motor[MOTOR_0].pwm = 100;
                 motor[MOTOR_0].dir = BACK;
             }
@@ -2611,7 +2620,8 @@
                     motor[MOTOR_0].dir = BACK;
                 }
             }
-        } else if(mode==25) {
+        } 
+        else if(mode==25) {
             switch(g[4]) {
                 case 98:
                     motor[TIRE_FR].pwm = 60;
@@ -2705,17 +2715,18 @@
                     break;
             }
             if(g[1]==98) {
-                mode=31;
+                mode=33;
             }
         }
-    } else {
+    } 
+    else {
         if(mode==21) {
             motor[TIRE_FR].pwm = 30;
             motor[TIRE_FR].dir = FOR;
-            motor[TIRE_FL].pwm = 0;
-            motor[TIRE_FL].dir = FREE;
-            motor[TIRE_BR].pwm = 0;
-            motor[TIRE_BR].dir = FREE;
+            motor[TIRE_FL].pwm = 255;
+            motor[TIRE_FL].dir = BRAKE;
+            motor[TIRE_BR].pwm = 255;
+            motor[TIRE_BR].dir = BRAKE;
             motor[TIRE_BL].pwm = 30;
             motor[TIRE_BL].dir = BACK;
             if(g[1]==0) {
@@ -2724,14 +2735,15 @@
                 normal=40;
                 slow=20;
             }
-        } else if(mode==22) {
+        } 
+        else if(mode==22) {
             if(g[1]==98) {
                 slow=20;
-                normal=20;
-                fast=30;
+                normal=30;
+                fast=40;
             }
             if(g[3]==0){
-                slow=30;
+                slow=20;
                 normal=40;
                 fast=60;
                 mode=23;
@@ -2739,8 +2751,8 @@
             switch(g[1]) {
                 case 98:
                     solenoid.solenoid4 = SOLENOID_OFF;
-                    fast=30;
-                    normal=20;
+                    fast=40;
+                    normal=30;
                     slow=20;
                     motor[TIRE_FR].pwm = normal;
                     motor[TIRE_FR].dir = FOR;
@@ -2835,34 +2847,35 @@
                         mtc=false;
                         break;
                     case 255:
-                        motor[TIRE_FL].pwm += 5;
+                        motor[TIRE_FL].pwm += 3;
                         mtc=false;
                         break;
                     case 253:
-                        motor[TIRE_FL].pwm += 10;
+                        motor[TIRE_FL].pwm += 6;
                         mtc=false;
                         break;
                     case 254:
-                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_FL].pwm += 9;
                         motor[TIRE_FR].pwm = 0;
                         mtc=false;
                         break;
                     case 1:
-                        motor[TIRE_FR].pwm += 5;
+                        motor[TIRE_FR].pwm += 3;
                         mtc=false;
                         break;
                     case 3:
-                        motor[TIRE_FR].pwm += 10;
+                        motor[TIRE_FR].pwm += 6;
                         mtc=false;
                         break;
                     case 2:
-                        motor[TIRE_FR].pwm += 20;
+                        motor[TIRE_FR].pwm += 9;
                         motor[TIRE_FL].pwm = 0;
                         mtc=false;
                         break;
                 }
             }
-        }else if(mode==23) {
+        }
+        else if(mode==23) {
             if(UPLS==true||DOLS==true) {
                 motor[MOTOR_0].pwm = 200;
                 motor[MOTOR_0].dir = BRAKE;
@@ -2871,7 +2884,8 @@
                 slow=20;
                 countss=0;
                 mode=24;
-            } else {
+            } 
+            else {
                 motor[MOTOR_0].pwm = 100;
                 motor[MOTOR_0].dir = BACK;
             }
@@ -2883,15 +2897,16 @@
             motor[TIRE_BR].dir = BRAKE;
             motor[TIRE_BL].pwm = 100;
             motor[TIRE_BL].dir = BRAKE;
-        } else if(mode==24) {
+        } 
+        else if(mode==24) {
             if(g[1]==98&&countss>=40000) {
-                mode=31;
+                mode=33;
                 countss=0;
             }
             switch(g[1]) {
                 case 98:
-                    fast=30;
-                    normal=20;
+                    fast=40;
+                    normal=30;
                     slow=20;
                     motor[TIRE_FR].pwm = normal;
                     motor[TIRE_FR].dir = FOR;
@@ -2986,28 +3001,28 @@
                         mtc=false;
                         break;
                     case 255:
-                        motor[TIRE_FL].pwm += 5;
+                        motor[TIRE_FL].pwm += 3;
                         mtc=false;
                         break;
                     case 253:
-                        motor[TIRE_FL].pwm += 10;
+                        motor[TIRE_FL].pwm += 6;
                         mtc=false;
                         break;
                     case 254:
-                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_FL].pwm += 9;
                         motor[TIRE_FR].pwm = 0;
                         mtc=false;
                         break;
                     case 1:
-                        motor[TIRE_FR].pwm += 5;
+                        motor[TIRE_FR].pwm += 3;
                         mtc=false;
                         break;
                     case 3:
-                        motor[TIRE_FR].pwm += 10;
+                        motor[TIRE_FR].pwm += 6;
                         mtc=false;
                         break;
                     case 2:
-                        motor[TIRE_FR].pwm += 20;
+                        motor[TIRE_FR].pwm += 9;
                         motor[TIRE_FL].pwm = 0;
                         mtc=false;
                         break;
@@ -3015,6 +3030,8 @@
             }
         }
     }
+    
+    /*
     if(mode==31) {
         motor[TIRE_FR].pwm = 0;
         motor[TIRE_FR].dir = FREE;
@@ -3041,65 +3058,68 @@
             mode=33;
             countss=0;
         }
-    } else if(mode==33) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 40;
+    } 
+    */
+    if(mode==33) {
+        motor[TIRE_FR].pwm = 255;
+        motor[TIRE_FR].dir = BRAKE;
+        motor[TIRE_FL].pwm = 45;
         motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 40;
+        motor[TIRE_BR].pwm = 45;
         motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(g[3]==0&&g[2]==0) {
+        motor[TIRE_BL].pwm = 255;
+        motor[TIRE_BL].dir = BRAKE;
+        if(g[2]==0) {
             cross=0;
             countss=0;
             mode=40;
         }
-    } else if(mode==40) {
+    } 
+    else if(mode==40) {
         switch(g[3]) {
             case 98:
-                motor[TIRE_FR].pwm = normal;
+                motor[TIRE_FR].pwm = normal+30;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = normal;
+                motor[TIRE_FL].pwm = normal+30;
                 motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = normal;
+                motor[TIRE_BR].pwm = normal+30;
                 motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = normal;
+                motor[TIRE_BL].pwm = normal+30;
                 motor[TIRE_BL].dir = FOR;
-                if(countss>10000) {
+                if(countss>30000) {
                     cross++;
                     countss=0;
                 }
                 mtc2=true;
                 break;
             case 0:
-                motor[TIRE_FR].pwm = fast;
+                motor[TIRE_FR].pwm = fast+30;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = fast;
+                motor[TIRE_FL].pwm = fast+30;
                 motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = fast;
+                motor[TIRE_BR].pwm = fast+30;
                 motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = fast;
+                motor[TIRE_BL].pwm = fast+30;
                 motor[TIRE_BL].dir = FOR;
                 mtc2=true;
                 break;
             case 255:
-                motor[TIRE_FR].pwm = slow;
+                motor[TIRE_FR].pwm = slow+30;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = fast;
+                motor[TIRE_FL].pwm = fast+30;
                 motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = fast;
+                motor[TIRE_BR].pwm = fast+30;
                 motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = slow;
+                motor[TIRE_BL].pwm = slow+30;
                 motor[TIRE_BL].dir = FOR;
                 mtc2=true;
                 break;
             case 253:
                 motor[TIRE_FR].pwm = 0;
                 motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = slow;
+                motor[TIRE_FL].pwm = slow+30;
                 motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = slow;
+                motor[TIRE_BR].pwm = slow+30;
                 motor[TIRE_BR].dir = FOR;
                 motor[TIRE_BL].pwm = 0;
                 motor[TIRE_BL].dir = FREE;
@@ -3108,44 +3128,44 @@
             case 254:
                 motor[TIRE_FR].pwm = 0;
                 motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = normal;
+                motor[TIRE_FL].pwm = normal+30;
                 motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = normal;
+                motor[TIRE_BR].pwm = normal+30;
                 motor[TIRE_BR].dir = FOR;
                 motor[TIRE_BL].pwm = 0;
                 motor[TIRE_BL].dir = FREE;
                 mtc2=true;
                 break;
             case 1:
-                motor[TIRE_FR].pwm = fast;
+                motor[TIRE_FR].pwm = fast+30;
                 motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = slow;
+                motor[TIRE_FL].pwm = slow+30;
                 motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = slow;
+                motor[TIRE_BR].pwm = slow+30;
                 motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = fast;
+                motor[TIRE_BL].pwm = fast+30;
                 motor[TIRE_BL].dir = FOR;
                 mtc2=true;
                 break;
             case 3:
-                motor[TIRE_FR].pwm = slow;
+                motor[TIRE_FR].pwm = slow+30;
                 motor[TIRE_FR].dir = BACK;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
                 motor[TIRE_BR].pwm = 0;
                 motor[TIRE_BR].dir = FREE;
-                motor[TIRE_BL].pwm = slow;
+                motor[TIRE_BL].pwm = slow+30;
                 motor[TIRE_BL].dir = FOR;
                 mtc2=true;
                 break;
             case 2:
-                motor[TIRE_FR].pwm = normal;
+                motor[TIRE_FR].pwm = normal+30;
                 motor[TIRE_FR].dir = BACK;
                 motor[TIRE_FL].pwm = 0;
                 motor[TIRE_FL].dir = FREE;
                 motor[TIRE_BR].pwm = 0;
                 motor[TIRE_BR].dir = FREE;
-                motor[TIRE_BL].pwm = normal;
+                motor[TIRE_BL].pwm = normal+30;
                 motor[TIRE_BL].dir = FOR;
                 mtc2=true;
                 break;
@@ -3156,48 +3176,42 @@
                     mtc2=false;
                     break;
                 case 255:
-                    motor[TIRE_FL].pwm += 5;
+                    motor[TIRE_FR].pwm += 3;
                     mtc2=false;
                     break;
                 case 253:
-                    motor[TIRE_FL].pwm += 10;
+                    motor[TIRE_FR].pwm += 6;
                     mtc2=false;
                     break;
                 case 254:
-                    motor[TIRE_FL].pwm += 20;
-                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_FR].pwm += 9;
+                    motor[TIRE_BR].pwm = 0;
                     mtc2=false;
                     break;
                 case 1:
-                    motor[TIRE_BL].pwm += 5;
+                    motor[TIRE_BR].pwm += 3;
                     mtc2=false;
                     break;
                 case 3:
-                    motor[TIRE_BL].pwm += 10;
+                    motor[TIRE_BR].pwm += 6;
                     mtc2=false;
                     break;
                 case 2:
-                    motor[TIRE_BL].pwm += 20;
-                    motor[TIRE_FL].pwm = 0;
+                    motor[TIRE_BR].pwm += 9;
+                    motor[TIRE_FR].pwm = 0;
                     mtc2=false;
                     break;
             }
         }
         
-        /*
-        if(LIF||LIB) {
-            mode=41;
-            countss=0;
-            cross=0;
-        }
-        */
         if(YELLOW) {
             if(cross==1) {
                 mode=41;
                 countss=0;
                 cross=0;
             }
-        } else {
+        } 
+        else {
             if(cross==3) {
                 mode=41;
                 countss=0;
@@ -3205,18 +3219,19 @@
             }
         }
         
-    } else if(mode==41) {
+    } 
+    else if(mode==41) {
         if(LIF||LIB) {
             mode=42;
         }
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
+        motor[TIRE_FR].pwm = 255;
+        motor[TIRE_FR].dir = BRAKE;
         motor[TIRE_FL].pwm = 40;
         motor[TIRE_FL].dir = BACK;
         motor[TIRE_BR].pwm = 40;
         motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
+        motor[TIRE_BL].pwm = 255;
+        motor[TIRE_BL].dir = BRAKE;
         if(g[1]==0) {
             countss=0;
             mode=70;
@@ -3224,7 +3239,8 @@
             fast=100;
             slow=60;
         }
-    } else if(mode==42) {
+    } 
+    else if(mode==42) {
         motor[TIRE_FR].pwm = 40;
         motor[TIRE_FR].dir = FOR;
         motor[TIRE_FL].pwm = 0;
@@ -3237,7 +3253,8 @@
             countss=0;
             mode=70;
         }
-    } else if(mode==70) {
+    } 
+    else if(mode==70) {
         switch(g[1]) {
             case 99:
                 if(countss>=100000) {
@@ -3338,34 +3355,35 @@
                     mtc=false;
                     break;
                 case 255:
-                    motor[TIRE_FL].pwm += 5;
+                    motor[TIRE_FL].pwm += 3;
                     mtc=false;
                     break;
                 case 253:
-                    motor[TIRE_FL].pwm += 10;
+                    motor[TIRE_FL].pwm += 6;
                     mtc=false;
                     break;
                 case 254:
-                    motor[TIRE_FL].pwm += 20;
+                    motor[TIRE_FL].pwm += 9;
                     motor[TIRE_FR].pwm = 0;
                     mtc=false;
                     break;
                 case 1:
-                    motor[TIRE_FR].pwm += 5;
+                    motor[TIRE_FR].pwm += 3;
                     mtc=false;
                     break;
                 case 3:
-                    motor[TIRE_FR].pwm += 10;
+                    motor[TIRE_FR].pwm += 6;
                     mtc=false;
                     break;
                 case 2:
-                    motor[TIRE_FR].pwm += 20;
+                    motor[TIRE_FR].pwm += 9;
                     motor[TIRE_FL].pwm = 0;
                     mtc=false;
                     break;
             }
         }
-    } else if(mode==100) {
+    } 
+    else if(mode==100) {
         motor[TIRE_FR].pwm = 50;
         motor[TIRE_FR].dir = FOR;
         motor[TIRE_FL].pwm = 50;
@@ -3374,9 +3392,8 @@
         motor[TIRE_BR].dir = FOR;
         motor[TIRE_BL].pwm = 50;
         motor[TIRE_BL].dir = BACK;
-    } else {
-    }
-
+    } 
+    
 }
 #endif