aa

Dependencies:   mbed TrapezoidControl QEI

Revision:
29:c78a46f51209
Parent:
28:9cd36721cf83
Child:
30:9450dc1d53cc
diff -r 9cd36721cf83 -r c78a46f51209 System/Process/Process.cpp
--- a/System/Process/Process.cpp	Wed Sep 18 11:36:53 2019 +0000
+++ b/System/Process/Process.cpp	Thu Sep 19 05:42:23 2019 +0000
@@ -291,6 +291,8 @@
 bool dz4=true;
 bool dz4i=false;
 
+bool zone;
+
 int mode =1;
 int cross=0;//十字数える用
 int count=100000;//wait代替え
@@ -414,232 +416,37 @@
     count++;
     if(mode==0&&StertSW) {
         if(ThSW) {
+            zone=ZoneSW;
             Twsh=1;
             mode=1;
         } else {
+            zone=ZoneSW;
             Twsh=2;
             mode=1;
         }
     }
-    if(mode==1) {//スタートゾーンから白線検知
-        motor[TIRE_FR].pwm = 30;
-        motor[TIRE_FR].dir = BACK;
-        motor[TIRE_FL].pwm = 30;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 30;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 30;
-        motor[TIRE_BL].dir = FOR;
-        if(g[2]==0) {
-            count=100000;
-            cross=0;
-            mode=2;
-        }
-    } else if(mode==2) {//横移動
-        if(g[2]==0) {
-            count=100000;
-            cross=0;
-            mode=3;
-            mtc2=true;
-        } else {
+    if(ZoneSW==false) {
+        if(mode==1) {//スタートゾーンから白線検知
             motor[TIRE_FR].pwm = 30;
-            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FR].dir = BACK;
             motor[TIRE_FL].pwm = 30;
             motor[TIRE_FL].dir = FOR;
             motor[TIRE_BR].pwm = 30;
             motor[TIRE_BR].dir = BACK;
             motor[TIRE_BL].pwm = 30;
-            motor[TIRE_BL].dir = BACK;
-        }
-    } else if(mode==3) { //横ライントレースから縦ライントレースへ
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 20;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 20;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(count>100000&&g[0]==0) {
-            count=0;
-            mode=10;
-        }
-    } else if(mode==4) { //横ライントレースから縦ライントレースへ
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = BACK;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = FOR;
-        if(count>30000&&g[0]==0) {
-            count=0;
-            cross=0;
-            mode=10;
-        }
-    } else if(g[0]!=99&&mode==10) { //縦ライントレース
-        switch(g[0]) {
-            case 98:
-                motor[TIRE_FR].pwm = 30;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 30;
-                motor[TIRE_BL].dir = FOR;
-                if(count>100000) {
-                    cross++;
-                    count=0;
-                }
-                mtc=true;
-                if(cross==Twsh) {
-                    mode=11;
-                    count=0;
-                }
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 20;
-                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 = 20;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 254:
-                motor[TIRE_FR].pwm = 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 = 30;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 1:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc=true;
-                break;
-            case 2:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                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;
-                mtc=true;
-                break;
-        }
-        if(g[0]!=98&&mtc==true) {
-            switch(g[1]) {
-                case 0:
-                    mtc=false;
-                    break;
-                case 255:
-                    motor[TIRE_BR].pwm += 5;
-                    mtc=false;
-                    break;
-                case 253:
-                    motor[TIRE_BR].pwm += 10;
-                    mtc=false;
-                    break;
-                case 254:
-                    motor[TIRE_BR].pwm += 20;
-                    motor[TIRE_BL].pwm = 0;
-                    mtc=false;
-                    break;
-                case 1:
-                    motor[TIRE_BL].pwm += 5;
-                    mtc=false;
-                    break;
-                case 3:
-                    motor[TIRE_BL].pwm += 10;
-                    mtc=false;
-                    break;
-                case 2:
-                    motor[TIRE_BL].pwm += 20;
-                    motor[TIRE_BR].pwm = 0;
-                    mtc=false;
-                    break;
+            motor[TIRE_BL].dir = FOR;
+            if(g[2]==0) {
+                count=100000;
+                cross=0;
+                mode=2;
             }
-        }
-    } else if(mode==11) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(count>5000&&g[2]==0) {
-            count=0;
-            mode=12;
-        }
-    } else if(mode==12) {
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = FOR;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = BACK;
-        if(count>10000&&g[2]==0) {
-            count=0;
-            cross=0;
-            mode=20;
-        }
-    } else if(mode==20) {
-        switch(g[2]) {
-            case 98:
+        } else if(mode==2) {//横移動
+            if(g[2]==0) {
+                count=100000;
+                cross=0;
+                mode=3;
+                mtc2=true;
+            } else {
                 motor[TIRE_FR].pwm = 30;
                 motor[TIRE_FR].dir = FOR;
                 motor[TIRE_FL].pwm = 30;
@@ -648,937 +455,2296 @@
                 motor[TIRE_BR].dir = BACK;
                 motor[TIRE_BL].pwm = 30;
                 motor[TIRE_BL].dir = BACK;
-                if(count>70000) {
-                    cross++;
-                    count=0;
+            }
+        } else if(mode==3) { //横ライントレースから縦ライントレースへ
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 20;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 20;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>100000&&g[0]==0) {
+                count=0;
+                mode=10;
+            }
+        } else if(mode==4) { //横ライントレースから縦ライントレースへ
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = BACK;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>30000&&g[0]==0) {
+                count=0;
+                cross=0;
+                mode=10;
+            }
+        } else if(g[0]!=99&&mode==10) { //縦ライントレース
+            switch(g[0]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>100000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc=true;
+                    if(cross==Twsh) {
+                        mode=11;
+                        count=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 254:
+                    motor[TIRE_FR].pwm = 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 = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    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;
+                    mtc=true;
+                    break;
+            }
+            if(g[0]!=98&&mtc==true) {
+                switch(g[1]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_BR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_BR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_BR].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_BR].pwm = 0;
+                        mtc=false;
+                        break;
                 }
-                mtc2=true;
-                if(cross==3) {
-                    mode=21;
-                    count=0;
-                    cross=0;
+            }
+        } else if(mode==11) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[2]==0) {
+                count=0;
+                mode=12;
+            }
+        } else if(mode==12) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>10000&&g[2]==0) {
+                count=0;
+                cross=0;
+                mode=20;
+            }
+        } else if(mode==20) {
+            switch(g[2]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    if(count>70000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc2=true;
+                    if(cross==3) {
+                        mode=21;
+                        count=0;
+                        cross=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
+                    break;
+                case 254:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    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;
+                    mtc2=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 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 = 20;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
+                    break;
+                case 2:
+                    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_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
+                    break;
+            }
+            if(g[2]!=98&&mtc2==true) {
+                switch(g[3]) {
+                    case 0:
+                        mtc2=false;
+                        break;
+                    case 255:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 253:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 254:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc2=false;
+                        break;
+                    case 1:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 3:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 2:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc2=false;
+                        break;
+                }
+            }
+        } else if(mode==21) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>2000&&g[0]==0) {
+                count=0;
+                mode=22;
+            }
+        } else if(mode==22) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = BACK;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>5000&&g[0]==0) {
+                count=0;
+                cross=0;
+                mode=30;
+            }
+        } else if(mode==30) {
+            switch(g[0]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>100000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc=true;
+                    if(cross==1) {
+                        mode=31;
+                        count=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 254:
+                    motor[TIRE_FR].pwm = 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 = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    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;
+                    mtc=true;
+                    break;
+            }
+            if(g[0]!=98&&mtc==true) {
+                switch(g[1]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_BR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_BR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_BR].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_BR].pwm = 0;
+                        mtc=false;
+                        break;
                 }
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = BACK;
-                mtc2=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = BACK;
+            }
+        } else if(mode==31) {
+            motor[TIRE_FR].pwm = 15;
+            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 = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                mode=32;
+            }
+        } else if(mode==32) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                cross=0;
+                mode=40;
+            }
+        } else if(mode==40) {
+            switch(g[3]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>30000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc2=true;
+                    if(cross==1) {
+                        mode=41;
+                        count=0;
+                        cross=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
+                    break;
+                case 254:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 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 = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 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 = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+            }
+            if(g[2]!=98&&mtc2==true) {
+                switch(g[2]) {
+                    case 0:
+                        mtc2=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc2=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc2=false;
+                        break;
+                }
+            }
+        } else if(mode==41) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=42;
+            }
+        } else if(mode==42) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=50;
+            }
+        } else if(mode==50) {
+            switch(g[1]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    if(count>100000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc=true;
+                    if(cross==1) {
+                        mode=51;
+                        count=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 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 = 20;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 254:
+                    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_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+            }
+            if(g[1]!=98&&mtc==true) {
+                switch(g[0]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_FR].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_FR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_FR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_FR].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc=false;
+                        break;
+                }
+            }
+        } else if(mode==51) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                mode=52;
+            }
+        } else if(mode==52) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = BACK;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                cross=0;
+                mode=60;
+            }
+        } else if(mode==60) {
+            switch(g[3]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>50000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc2=true;
+                    if(cross==2) {
+                        mode=61;
+                        count=0;
+                        cross=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
+                    break;
+                case 254:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 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 = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 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 = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+            }
+            if(g[2]!=98&&mtc2==true) {
+                switch(g[2]) {
+                    case 0:
+                        mtc2=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc2=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc2=false;
+                        break;
+                }
+            }
+        } else if(mode==61) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=62;
+            }
+        } else if(mode==62) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=70;
+            }
+        } else if(mode==70) {
+            switch(g[1]) {
+                case 99:
+                    if(count>=100000) {
+                        mode=100;
+                    }
+                    break;
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 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 = 20;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 254:
+                    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_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+            }
+            if(g[1]!=98&&mtc==true) {
+                switch(g[0]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_FR].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_FR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_FR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_FR].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc=false;
+                        break;
+                }
+            }
+        } else if(mode==100) {
+            motor[TIRE_FR].pwm = 20;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 20;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 23;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 20;
+            motor[TIRE_BL].dir = BACK;
+        } else {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = BRAKE;
+            motor[TIRE_FL].pwm = 0;
+            motor[TIRE_FL].dir = BRAKE;
+            motor[TIRE_BR].pwm = 0;
+            motor[TIRE_BR].dir = BRAKE;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = BRAKE;
+        }
+    } else {//////////////////////////////////////////////////これより別ゾーン用/////////////////////////////////////////////////////////////////////////////////
+        if(mode==1) {//スタートゾーンから白線検知
+            motor[TIRE_FR].pwm = 30;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 30;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 30;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 30;
+            motor[TIRE_BL].dir = BACK;
+            if(g[2]==0) {
+                count=100000;
+                cross=0;
+                mode=2;
+            }
+        } else if(mode==2) {//横移動
+            if(g[2]==0) {
+                count=100000;
+                cross=0;
+                mode=3;
                 mtc2=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc2=true;
-                break;
-            case 254:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                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;
-                mtc2=true;
-                break;
-            case 1:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = BACK;
-                mtc2=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 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 = 20;
-                motor[TIRE_BL].dir = BACK;
-                mtc2=true;
-                break;
-            case 2:
+            } else {
                 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_BL].pwm = 30;
-                motor[TIRE_BL].dir = BACK;
-                mtc2=true;
-                break;
-        }
-        if(g[2]!=98&&mtc2==true) {
-            switch(g[3]) {
-                case 0:
-                    mtc2=false;
-                    break;
-                case 255:
-                    motor[TIRE_BL].pwm += 5;
-                    mtc2=false;
-                    break;
-                case 253:
-                    motor[TIRE_BL].pwm += 10;
-                    mtc2=false;
-                    break;
-                case 254:
-                    motor[TIRE_BL].pwm += 20;
-                    motor[TIRE_FL].pwm = 0;
-                    mtc2=false;
-                    break;
-                case 1:
-                    motor[TIRE_FL].pwm += 5;
-                    mtc2=false;
-                    break;
-                case 3:
-                    motor[TIRE_FL].pwm += 10;
-                    mtc2=false;
-                    break;
-                case 2:
-                    motor[TIRE_FL].pwm += 20;
-                    motor[TIRE_BL].pwm = 0;
-                    mtc2=false;
-                    break;
-            }
-        }
-    } else if(mode==21) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(count>2000&&g[0]==0) {
-            count=0;
-            mode=22;
-        }
-    } else if(mode==22) {
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = BACK;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = FOR;
-        if(count>5000&&g[0]==0) {
-            count=0;
-            cross=0;
-            mode=30;
-        }
-    } else if(mode==30) {
-        switch(g[0]) {
-            case 98:
-                motor[TIRE_FR].pwm = 30;
-                motor[TIRE_FR].dir = BACK;
                 motor[TIRE_FL].pwm = 30;
                 motor[TIRE_FL].dir = FOR;
                 motor[TIRE_BR].pwm = 30;
                 motor[TIRE_BR].dir = BACK;
                 motor[TIRE_BL].pwm = 30;
-                motor[TIRE_BL].dir = FOR;
-                if(count>100000) {
-                    cross++;
-                    count=0;
-                }
-                mtc=true;
-                if(cross==1) {
-                    mode=31;
-                    count=0;
-                }
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 20;
-                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 = 20;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 254:
-                motor[TIRE_FR].pwm = 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 = 30;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 1:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = FOR;
-                mtc=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = FOR;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = BACK;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc=true;
-                break;
-            case 2:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                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;
-                mtc=true;
-                break;
-        }
-        if(g[0]!=98&&mtc==true) {
-            switch(g[1]) {
+                motor[TIRE_BL].dir = BACK;
+            }
+        } else if(mode==3) { //横ライントレースから縦ライントレースへ
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 20;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 20;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>100000&&g[0]==0) {
+                count=0;
+                mode=10;
+            }
+        } else if(mode==4) { //横ライントレースから縦ライントレースへ
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = BACK;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>30000&&g[0]==0) {
+                count=0;
+                cross=0;
+                mode=10;
+            }
+        } else if(g[0]!=99&&mode==10) { //縦ライントレース
+            switch(g[0]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    if(count>100000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc=true;
+                    if(cross==Twsh) {
+                        mode=11;
+                        count=0;
+                    }
+                    break;
                 case 0:
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
                     break;
                 case 255:
-                    motor[TIRE_BR].pwm += 5;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
                     break;
                 case 253:
-                    motor[TIRE_BR].pwm += 10;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 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 = 20;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
                     break;
                 case 254:
-                    motor[TIRE_BR].pwm += 20;
-                    motor[TIRE_BL].pwm = 0;
-                    mtc=false;
+                    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_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
                     break;
                 case 1:
-                    motor[TIRE_BL].pwm += 5;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
                     break;
                 case 3:
-                    motor[TIRE_BL].pwm += 10;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
                     break;
                 case 2:
-                    motor[TIRE_BL].pwm += 20;
-                    motor[TIRE_BR].pwm = 0;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
                     break;
             }
-        }
-    } else if(mode==31) {
-        motor[TIRE_FR].pwm = 15;
-        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 = 15;
-        motor[TIRE_BL].dir = FOR;
-        if(count>5000&&g[3]==0) {
-            count=0;
-            mode=32;
-        }
-    } else if(mode==32) {
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = FOR;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = BACK;
-        if(count>5000&&g[3]==0) {
-            count=0;
-            cross=0;
-            mode=40;
-        }
-    } else if(mode==40) {
-        switch(g[3]) {
-            case 98:
-                motor[TIRE_FR].pwm = 30;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 30;
-                motor[TIRE_BL].dir = FOR;
-                if(count>30000) {
-                    cross++;
-                    count=0;
-                }
-                mtc2=true;
-                if(cross==1) {
-                    mode=41;
-                    count=0;
-                    cross=0;
+            if(g[0]!=98&&mtc==true) {
+                switch(g[1]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_BR].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BR].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc=false;
+                        break;
                 }
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc2=true;
-                break;
-            case 254:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 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 = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 20;
-                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 = 20;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 2:
-                motor[TIRE_FR].pwm = 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 = 30;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-        }
-        if(g[2]!=98&&mtc2==true) {
+            }
+        } else if(mode==11) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[2]==0) {
+                count=0;
+                mode=12;
+            }
+        } else if(mode==12) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>10000&&g[2]==0) {
+                count=0;
+                cross=0;
+                mode=20;
+            }
+        } else if(mode==20) {
             switch(g[2]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    if(count>70000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc2=true;
+                    if(cross==3) {
+                        mode=21;
+                        count=0;
+                        cross=0;
+                    }
+                    break;
                 case 0:
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
                     break;
                 case 255:
-                    motor[TIRE_FL].pwm += 5;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
                     break;
                 case 253:
-                    motor[TIRE_FL].pwm += 10;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
                     break;
                 case 254:
-                    motor[TIRE_FL].pwm += 20;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    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;
-                    mtc2=false;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
                     break;
                 case 1:
-                    motor[TIRE_BL].pwm += 5;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
                     break;
                 case 3:
-                    motor[TIRE_BL].pwm += 10;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 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 = 20;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
                     break;
                 case 2:
-                    motor[TIRE_BL].pwm += 20;
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
                     motor[TIRE_FL].pwm = 0;
-                    mtc2=false;
+                    motor[TIRE_FL].dir = FREE;
+                    motor[TIRE_BR].pwm = 0;
+                    motor[TIRE_BR].dir = FREE;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc2=true;
+                    break;
+            }
+            if(g[2]!=98&&mtc2==true) {
+                switch(g[3]) {
+                    case 0:
+                        mtc2=false;
+                        break;
+                    case 255:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 253:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 254:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc2=false;
+                        break;
+                    case 1:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 3:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 2:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc2=false;
+                        break;
+                }
+            }
+        } else if(mode==21) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>2000&&g[0]==0) {
+                count=0;
+                mode=22;
+            }
+        } else if(mode==22) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = BACK;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>5000&&g[0]==0) {
+                count=0;
+                cross=0;
+                mode=30;
+            }
+        } else if(mode==30) {
+            switch(g[0]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    if(count>100000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc=true;
+                    if(cross==1) {
+                        mode=31;
+                        count=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 20;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 0;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 0;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 20;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 254:
+                    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_BL].pwm = 30;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = FOR;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = BACK;
+                    mtc=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
                     break;
             }
-        }
-    } else if(mode==41) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(count>5000&&g[1]==0) {
-            count=0;
-            mode=42;
-        }
-    } else if(mode==42) {
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = FOR;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = BACK;
-        if(count>5000&&g[1]==0) {
-            count=0;
-            mode=50;
-        }
-    } else if(mode==50) {
-        switch(g[1]) {
-            case 98:
-                motor[TIRE_FR].pwm = 30;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 30;
-                motor[TIRE_BL].dir = BACK;
-                if(count>100000) {
-                    cross++;
-                    count=0;
-                }
-                mtc=true;
-                if(cross==1) {
-                    mode=51;
-                    count=0;
+            if(g[0]!=98&&mtc==true) {
+                switch(g[1]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_BR].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BR].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc=false;
+                        break;
                 }
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 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 = 20;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 254:
-                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_BL].pwm = 30;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 1:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc=true;
-                break;
-            case 2:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc=true;
-                break;
-        }
-        if(g[1]!=98&&mtc==true) {
-            switch(g[0]) {
+            }
+        } else if(mode==31) {
+            motor[TIRE_FR].pwm = 15;
+            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 = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                mode=32;
+            }
+        } else if(mode==32) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                cross=0;
+                mode=40;
+            }
+        } else if(mode==40) {
+            switch(g[3]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>30000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc2=true;
+                    if(cross==1) {
+                        mode=41;
+                        count=0;
+                        cross=0;
+                    }
+                    break;
                 case 0:
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 255:
-                    motor[TIRE_FL].pwm += 5;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 253:
-                    motor[TIRE_FL].pwm += 10;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
                     break;
                 case 254:
-                    motor[TIRE_FL].pwm += 20;
                     motor[TIRE_FR].pwm = 0;
-                    mtc=false;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 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 += 5;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 3:
-                    motor[TIRE_FR].pwm += 10;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 2:
-                    motor[TIRE_FR].pwm += 20;
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
                     motor[TIRE_FL].pwm = 0;
-                    mtc=false;
+                    motor[TIRE_FL].dir = FREE;
+                    motor[TIRE_BR].pwm = 0;
+                    motor[TIRE_BR].dir = FREE;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
+                    break;
+            }
+            if(g[2]!=98&&mtc2==true) {
+                switch(g[2]) {
+                    case 0:
+                        mtc2=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc2=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc2=false;
+                        break;
+                }
+            }
+        } else if(mode==41) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=42;
+            }
+        } else if(mode==42) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=50;
+            }
+        } else if(mode==50) {
+            switch(g[1]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>100000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc=true;
+                    if(cross==1) {
+                        mode=51;
+                        count=0;
+                    }
+                    break;
+                case 0:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 255:
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 253:
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 254:
+                    motor[TIRE_FR].pwm = 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 = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 1:
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
+                    break;
+                case 3:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
+                    break;
+                case 2:
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    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;
+                    mtc=true;
                     break;
             }
-        }
-    } else if(mode==51) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(count>5000&&g[3]==0) {
-            count=0;
-            mode=52;
-        }
-    } else if(mode==52) {
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = BACK;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = FOR;
-        if(count>5000&&g[3]==0) {
-            count=0;
-            cross=0;
-            mode=60;
-        }
-    } else if(mode==60) {
-        switch(g[3]) {
-            case 98:
-                motor[TIRE_FR].pwm = 30;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 30;
-                motor[TIRE_BL].dir = FOR;
-                if(count>50000) {
-                    cross++;
-                    count=0;
-                }
-                mtc2=true;
-                if(cross==2) {
-                    mode=61;
-                    count=0;
-                    cross=0;
+            if(g[1]!=98&&mtc==true) {
+                switch(g[0]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FR].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_FR].pwm = 0;
+                        mtc=false;
+                        break;
                 }
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc2=true;
-                break;
-            case 254:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 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 = 60;
-                motor[TIRE_FR].dir = BACK;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 20;
-                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 = 20;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-            case 2:
-                motor[TIRE_FR].pwm = 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 = 30;
-                motor[TIRE_BL].dir = FOR;
-                mtc2=true;
-                break;
-        }
-        if(g[2]!=98&&mtc2==true) {
-            switch(g[2]) {
+            }
+        } else if(mode==51) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                mode=52;
+            }
+        } else if(mode==52) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = BACK;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = FOR;
+            if(count>5000&&g[3]==0) {
+                count=0;
+                cross=0;
+                mode=60;
+            }
+        } else if(mode==60) {
+            switch(g[3]) {
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    if(count>50000) {
+                        cross++;
+                        count=0;
+                    }
+                    mtc2=true;
+                    if(cross==2) {
+                        mode=61;
+                        count=0;
+                        cross=0;
+                    }
+                    break;
                 case 0:
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 255:
-                    motor[TIRE_FL].pwm += 5;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 253:
-                    motor[TIRE_FL].pwm += 10;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
                     break;
                 case 254:
-                    motor[TIRE_FL].pwm += 20;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = FOR;
                     motor[TIRE_BL].pwm = 0;
-                    mtc2=false;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc2=true;
                     break;
                 case 1:
-                    motor[TIRE_BL].pwm += 5;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = BACK;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = FOR;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 3:
-                    motor[TIRE_BL].pwm += 10;
-                    mtc2=false;
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
                 case 2:
-                    motor[TIRE_BL].pwm += 20;
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
                     motor[TIRE_FL].pwm = 0;
-                    mtc2=false;
+                    motor[TIRE_FL].dir = FREE;
+                    motor[TIRE_BR].pwm = 0;
+                    motor[TIRE_BR].dir = FREE;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc2=true;
                     break;
             }
-        }
-    } else if(mode==61) {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = FREE;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = FREE;
-        if(count>5000&&g[1]==0) {
-            count=0;
-            mode=62;
-        }
-    } else if(mode==62) {
-        motor[TIRE_FR].pwm = 15;
-        motor[TIRE_FR].dir = FOR;
-        motor[TIRE_FL].pwm = 15;
-        motor[TIRE_FL].dir = FOR;
-        motor[TIRE_BR].pwm = 15;
-        motor[TIRE_BR].dir = BACK;
-        motor[TIRE_BL].pwm = 15;
-        motor[TIRE_BL].dir = BACK;
-        if(count>5000&&g[1]==0) {
-            count=0;
-            mode=70;
-        }
-    } else if(mode==70) {
-        switch(g[1]) {
-            case 99:
-                if(count>=100000) {
-                    mode=100;
+            if(g[2]!=98&&mtc2==true) {
+                switch(g[2]) {
+                    case 0:
+                        mtc2=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_BL].pwm = 0;
+                        mtc2=false;
+                        break;
+                    case 1:
+                        motor[TIRE_BL].pwm += 5;
+                        mtc2=false;
+                        break;
+                    case 3:
+                        motor[TIRE_BL].pwm += 10;
+                        mtc2=false;
+                        break;
+                    case 2:
+                        motor[TIRE_BL].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc2=false;
+                        break;
                 }
-                break;
-            case 98:
-                motor[TIRE_FR].pwm = 30;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 30;
-                motor[TIRE_BL].dir = BACK;
-                break;
-            case 0:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 255:
-                motor[TIRE_FR].pwm = 60;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 40;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 40;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 60;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 253:
-                motor[TIRE_FR].pwm = 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 = 20;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 254:
-                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_BL].pwm = 30;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 1:
-                motor[TIRE_FR].pwm = 40;
-                motor[TIRE_FR].dir = FOR;
-                motor[TIRE_FL].pwm = 60;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 60;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 40;
-                motor[TIRE_BL].dir = BACK;
-                mtc=true;
-                break;
-            case 3:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 20;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 20;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc=true;
-                break;
-            case 2:
-                motor[TIRE_FR].pwm = 0;
-                motor[TIRE_FR].dir = FREE;
-                motor[TIRE_FL].pwm = 30;
-                motor[TIRE_FL].dir = BACK;
-                motor[TIRE_BR].pwm = 30;
-                motor[TIRE_BR].dir = FOR;
-                motor[TIRE_BL].pwm = 0;
-                motor[TIRE_BL].dir = FREE;
-                mtc=true;
-                break;
-        }
-        if(g[1]!=98&&mtc==true) {
-            switch(g[0]) {
+            }
+        } else if(mode==61) {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = FREE;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = FREE;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=62;
+            }
+        } else if(mode==62) {
+            motor[TIRE_FR].pwm = 15;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 15;
+            motor[TIRE_FL].dir = FOR;
+            motor[TIRE_BR].pwm = 15;
+            motor[TIRE_BR].dir = BACK;
+            motor[TIRE_BL].pwm = 15;
+            motor[TIRE_BL].dir = BACK;
+            if(count>5000&&g[1]==0) {
+                count=0;
+                mode=70;
+            }
+        } else if(mode==70) {
+            switch(g[1]) {
+                case 99:
+                    if(count>=100000) {
+                        mode=100;
+                    }
+                    break;
+                case 98:
+                    motor[TIRE_FR].pwm = 30;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 30;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 30;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    break;
                 case 0:
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
                     break;
                 case 255:
-                    motor[TIRE_FL].pwm += 5;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 60;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 40;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 40;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 60;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
                     break;
                 case 253:
-                    motor[TIRE_FL].pwm += 10;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 20;
+                    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 = 20;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
                     break;
                 case 254:
-                    motor[TIRE_FL].pwm += 20;
-                    motor[TIRE_FR].pwm = 0;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 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 = 30;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
                     break;
                 case 1:
-                    motor[TIRE_FR].pwm += 5;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 40;
+                    motor[TIRE_FR].dir = BACK;
+                    motor[TIRE_FL].pwm = 60;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 60;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 40;
+                    motor[TIRE_BL].dir = FOR;
+                    mtc=true;
                     break;
                 case 3:
-                    motor[TIRE_FR].pwm += 10;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    motor[TIRE_FL].pwm = 20;
+                    motor[TIRE_FL].dir = FOR;
+                    motor[TIRE_BR].pwm = 20;
+                    motor[TIRE_BR].dir = BACK;
+                    motor[TIRE_BL].pwm = 0;
+                    motor[TIRE_BL].dir = FREE;
+                    mtc=true;
                     break;
                 case 2:
-                    motor[TIRE_FR].pwm += 20;
-                    motor[TIRE_FL].pwm = 0;
-                    mtc=false;
+                    motor[TIRE_FR].pwm = 0;
+                    motor[TIRE_FR].dir = FREE;
+                    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;
+                    mtc=true;
                     break;
             }
+            if(g[1]!=98&&mtc==true) {
+                switch(g[0]) {
+                    case 0:
+                        mtc=false;
+                        break;
+                    case 255:
+                        motor[TIRE_FR].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 253:
+                        motor[TIRE_FR].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 254:
+                        motor[TIRE_FR].pwm += 20;
+                        motor[TIRE_FL].pwm = 0;
+                        mtc=false;
+                        break;
+                    case 1:
+                        motor[TIRE_FL].pwm += 5;
+                        mtc=false;
+                        break;
+                    case 3:
+                        motor[TIRE_FL].pwm += 10;
+                        mtc=false;
+                        break;
+                    case 2:
+                        motor[TIRE_FL].pwm += 20;
+                        motor[TIRE_FR].pwm = 0;
+                        mtc=false;
+                        break;
+                }
+            }
+        } else if(mode==100) {
+            motor[TIRE_FR].pwm = 20;
+            motor[TIRE_FR].dir = FOR;
+            motor[TIRE_FL].pwm = 20;
+            motor[TIRE_FL].dir = BACK;
+            motor[TIRE_BR].pwm = 23;
+            motor[TIRE_BR].dir = FOR;
+            motor[TIRE_BL].pwm = 20;
+            motor[TIRE_BL].dir = BACK;
+        } else {
+            motor[TIRE_FR].pwm = 0;
+            motor[TIRE_FR].dir = BRAKE;
+            motor[TIRE_FL].pwm = 0;
+            motor[TIRE_FL].dir = BRAKE;
+            motor[TIRE_BR].pwm = 0;
+            motor[TIRE_BR].dir = BRAKE;
+            motor[TIRE_BL].pwm = 0;
+            motor[TIRE_BL].dir = BRAKE;
         }
-    } else if(mode==100) {
-        motor[TIRE_FR].pwm = 20;
-        motor[TIRE_FR].dir = FOR;
-        motor[TIRE_FL].pwm = 20;
-        motor[TIRE_FL].dir = BACK;
-        motor[TIRE_BR].pwm = 23;
-        motor[TIRE_BR].dir = FOR;
-        motor[TIRE_BL].pwm = 20;
-        motor[TIRE_BL].dir = BACK;
-    } else {
-        motor[TIRE_FR].pwm = 0;
-        motor[TIRE_FR].dir = BRAKE;
-        motor[TIRE_FL].pwm = 0;
-        motor[TIRE_FL].dir = BRAKE;
-        motor[TIRE_BR].pwm = 0;
-        motor[TIRE_BR].dir = BRAKE;
-        motor[TIRE_BL].pwm = 0;
-        motor[TIRE_BL].dir = BRAKE;
     }
 
 }