aa

Dependencies:   mbed

Committer:
yabahiro
Date:
Tue Nov 12 11:49:18 2019 +0000
Revision:
48:5562a99479e5
Parent:
47:a9cad8502999
Child:
49:697b4e9ce884
aa; ;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
t_yamamoto 0:669ef71cba68 1 #include "mbed.h"
t_yamamoto 0:669ef71cba68 2 #include "Process.h"
Ryosei 27:dd9f27fce7d1 3 #include <stdlib.h>
7ka884 4:ba9df71868df 4 #include "../../CommonLibraries/PID/PID.h"
t_yamamoto 0:669ef71cba68 5 #include "../../Communication/RS485/ActuatorHub/ActuatorHub.h"
M_souta 21:e3b58d675c1c 6 #include "../../Communication/RS485/LineHub/LineHub.h"
t_yamamoto 0:669ef71cba68 7 #include "../../Communication/Controller/Controller.h"
M_souta 30:8f092276b2ba 8 #include "../../Switch/Switch.h"
Ryosei 27:dd9f27fce7d1 9
t_yamamoto 0:669ef71cba68 10 #include "../../LED/LED.h"
t_yamamoto 0:669ef71cba68 11 #include "../../Safty/Safty.h"
t_yamamoto 0:669ef71cba68 12 #include "../Using.h"
t_yamamoto 0:669ef71cba68 13
t_yamamoto 0:669ef71cba68 14 using namespace SWITCH;
7ka884 4:ba9df71868df 15 using namespace PID_SPACE;
Ryosei 27:dd9f27fce7d1 16
M_souta 21:e3b58d675c1c 17 using namespace LINEHUB;
t_yamamoto 0:669ef71cba68 18
t_yamamoto 0:669ef71cba68 19 static CONTROLLER::ControllerData *controller;
t_yamamoto 0:669ef71cba68 20 ACTUATORHUB::MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:669ef71cba68 21 ACTUATORHUB::SOLENOID::SolenoidStatus solenoid;
t_yamamoto 0:669ef71cba68 22
t_yamamoto 0:669ef71cba68 23 static bool lock;
t_yamamoto 0:669ef71cba68 24 static bool processChangeComp;
t_yamamoto 0:669ef71cba68 25 static int current;
t_yamamoto 0:669ef71cba68 26
t_yamamoto 0:669ef71cba68 27 static void AllActuatorReset();
t_yamamoto 0:669ef71cba68 28
t_yamamoto 0:669ef71cba68 29 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 30 static void (*Process[USE_PROCESS_NUM])(void);
t_yamamoto 0:669ef71cba68 31 #endif
t_yamamoto 0:669ef71cba68 32
t_yamamoto 0:669ef71cba68 33 #pragma region USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 34
t_yamamoto 0:669ef71cba68 35 /*Replace here with the definition code of your variables.*/
t_yamamoto 0:669ef71cba68 36
kishibekairohan 2:c015739085d3 37
M_souta 30:8f092276b2ba 38 //Serial pc(USBTX, USBRX);
kishibekairohan 16:3f2c2d89372b 39
Ryosei 27:dd9f27fce7d1 40 const int omni[15][15] = {
Ryosei 27:dd9f27fce7d1 41 { 0, 5, 21, 47, 83, 130, 187, 255, 255, 255, 255, 255, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 42 { -5, 0, 5, 21, 47, 83, 130, 187, 193, 208, 234, 255, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 43 { -21, -5, 0, 5, 21, 47, 83, 130, 135, 151, 177, 213, 255, 255, 255 },
Ryosei 27:dd9f27fce7d1 44 { -47, -21, 5, 0, 5, 21, 47, 83, 88, 104, 130, 167, 213, 255, 255 },
Ryosei 27:dd9f27fce7d1 45 { -83, -47, -21, 5, 0, 5, 21, 47, 52, 68, 94, 130, 177, 234, 255 },
Ryosei 27:dd9f27fce7d1 46 { -130, -83, -47, -21, 5, 0, 5, 21, 26, 42, 68, 104, 151, 208, 255 },
Ryosei 27:dd9f27fce7d1 47 { -187, -130, -83, -47, -21, -5, 0, 5, 10, 26, 52, 88, 135, 193, 255 },
Ryosei 27:dd9f27fce7d1 48 { -255, -187, -130, -83, -47, -21, -5, 0, 5, 21, 47, 83, 130, 187, 255 },
Ryosei 27:dd9f27fce7d1 49 { -255, -193, -135, -88, -52, -26, -10, -5, 0, 5, 21, 47, 83, 130, 187 },
Ryosei 27:dd9f27fce7d1 50 { -255, -208, -151, -104, -68, -42, -26, -21, -5, 0, 5, 21, 47, 83, 130 },
Ryosei 27:dd9f27fce7d1 51 { -255, -234, -177, -130, -94, -68, -52, -47, -21, -7, 0, 7, 21, 47, 83 },
Ryosei 27:dd9f27fce7d1 52 { -255, -255, -213, -167, -130, -104, -88, -83, -47, -21, -5, 0, 5, 21, 47 },
Ryosei 27:dd9f27fce7d1 53 { -255, -255, -255, -213, -177, -151, -135, -130, -83, -47, -21, -5, 0, 5, 21 },
Ryosei 27:dd9f27fce7d1 54 { -255, -255, -255, -255, -234, -208, -193, -187, -130, -83, -47, -21, -5, 0, 5 },
Ryosei 27:dd9f27fce7d1 55 { -255, -255, -255, -255, -255, -255, -255, -255, -187, -130, -83, -47, -21, -5, 0 }
M_souta 21:e3b58d675c1c 56 };
M_souta 21:e3b58d675c1c 57
M_souta 21:e3b58d675c1c 58 const int curve[15] = { -204, -150, -104, -66, -38, -17, -4, 0, 4, 17, 38, 66, 104, 150, 204 };
M_souta 21:e3b58d675c1c 59
kishibekairohan 42:980af34f6fe3 60 uint8_t SetStatus(int pwmVal);
kishibekairohan 42:980af34f6fe3 61 uint8_t SetPWM(int pwmVal);
yabahiro 33:dd598bb23ad1 62
kishibekairohan 35:33c6cdba5630 63 DigitalIn EMC(PC_13); //非常停止確認用
yabahiro 33:dd598bb23ad1 64
yabahiro 33:dd598bb23ad1 65 bool start_flag = true;
yabahiro 33:dd598bb23ad1 66 bool UP_flag = false;
yabahiro 33:dd598bb23ad1 67 bool SW_flag = false;
yabahiro 33:dd598bb23ad1 68 bool Air_flag = false;
yabahiro 33:dd598bb23ad1 69 bool zyouge;
yabahiro 33:dd598bb23ad1 70 bool zyougedo;
yabahiro 33:dd598bb23ad1 71 bool dz2=true;
yabahiro 33:dd598bb23ad1 72 bool dz2i=false;
yabahiro 33:dd598bb23ad1 73 bool dz3=true;
yabahiro 33:dd598bb23ad1 74 bool dz3i=false;
yabahiro 33:dd598bb23ad1 75 bool dz4=true;
yabahiro 33:dd598bb23ad1 76 bool dz4i=false;
yabahiro 33:dd598bb23ad1 77 bool zone;
yabahiro 33:dd598bb23ad1 78 bool through=false;
yabahiro 33:dd598bb23ad1 79 bool counts=false;
yabahiro 33:dd598bb23ad1 80 bool mtc=false;
yabahiro 33:dd598bb23ad1 81 bool mtc2 = false;
yabahiro 33:dd598bb23ad1 82 bool emcs=false;
yabahiro 33:dd598bb23ad1 83 bool kiri;
yabahiro 33:dd598bb23ad1 84
yabahiro 33:dd598bb23ad1 85 int g[8];
yabahiro 33:dd598bb23ad1 86 int Twsh;
yabahiro 38:40e7fdf3c694 87 int testmode =0;
yabahiro 33:dd598bb23ad1 88 int mode =0;
yabahiro 33:dd598bb23ad1 89 int cross=0;//十字数える用
yabahiro 33:dd598bb23ad1 90 int cros=0;
yabahiro 33:dd598bb23ad1 91 int countss=100000;//wait代替え
yabahiro 33:dd598bb23ad1 92
yabahiro 33:dd598bb23ad1 93 ///*********PWM調整用*********///
kishibekairohan 41:99a1158f3eca 94
kishibekairohan 42:980af34f6fe3 95 int fast = 60;
yabahiro 33:dd598bb23ad1 96 int normal = 40;
yabahiro 46:68296caae1af 97 int slow = 25;
yabahiro 33:dd598bb23ad1 98
t_yamamoto 0:669ef71cba68 99 #pragma endregion USER-DEFINED_VARIABLES_AND_PROTOTYPE
t_yamamoto 0:669ef71cba68 100
t_yamamoto 0:669ef71cba68 101 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 102 #if USE_PROCESS_NUM>0
t_yamamoto 0:669ef71cba68 103 static void Process0(void);
t_yamamoto 0:669ef71cba68 104 #endif
t_yamamoto 0:669ef71cba68 105 #if USE_PROCESS_NUM>1
t_yamamoto 0:669ef71cba68 106 static void Process1(void);
t_yamamoto 0:669ef71cba68 107 #endif
t_yamamoto 0:669ef71cba68 108 #if USE_PROCESS_NUM>2
t_yamamoto 0:669ef71cba68 109 static void Process2(void);
t_yamamoto 0:669ef71cba68 110 #endif
t_yamamoto 0:669ef71cba68 111 #if USE_PROCESS_NUM>3
t_yamamoto 0:669ef71cba68 112 static void Process3(void);
t_yamamoto 0:669ef71cba68 113 #endif
t_yamamoto 0:669ef71cba68 114 #if USE_PROCESS_NUM>4
t_yamamoto 0:669ef71cba68 115 static void Process4(void);
t_yamamoto 0:669ef71cba68 116 #endif
t_yamamoto 0:669ef71cba68 117 #if USE_PROCESS_NUM>5
t_yamamoto 0:669ef71cba68 118 static void Process5(void);
t_yamamoto 0:669ef71cba68 119 #endif
t_yamamoto 0:669ef71cba68 120 #if USE_PROCESS_NUM>6
t_yamamoto 0:669ef71cba68 121 static void Process6(void);
t_yamamoto 0:669ef71cba68 122 #endif
t_yamamoto 0:669ef71cba68 123 #if USE_PROCESS_NUM>7
t_yamamoto 0:669ef71cba68 124 static void Process7(void);
t_yamamoto 0:669ef71cba68 125 #endif
t_yamamoto 0:669ef71cba68 126 #if USE_PROCESS_NUM>8
t_yamamoto 0:669ef71cba68 127 static void Process8(void);
t_yamamoto 0:669ef71cba68 128 #endif
t_yamamoto 0:669ef71cba68 129 #if USE_PROCESS_NUM>9
t_yamamoto 0:669ef71cba68 130 static void Process9(void);
t_yamamoto 0:669ef71cba68 131 #endif
t_yamamoto 0:669ef71cba68 132 #endif
t_yamamoto 0:669ef71cba68 133
t_yamamoto 0:669ef71cba68 134 void SystemProcessInitialize()
t_yamamoto 0:669ef71cba68 135 {
Ryosei 27:dd9f27fce7d1 136 #pragma region USER-DEFINED_VARIABLE_INIT
Ryosei 27:dd9f27fce7d1 137 /*Replace here with the initialization code of your variables.*/
Ryosei 27:dd9f27fce7d1 138
Ryosei 27:dd9f27fce7d1 139 #pragma endregion USER-DEFINED_VARIABLE_INIT
Ryosei 27:dd9f27fce7d1 140
Ryosei 27:dd9f27fce7d1 141 lock = true;
Ryosei 27:dd9f27fce7d1 142 processChangeComp = true;
Ryosei 27:dd9f27fce7d1 143 current = DEFAULT_PROCESS;
t_yamamoto 0:669ef71cba68 144
Ryosei 27:dd9f27fce7d1 145 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 146 #if USE_PROCESS_NUM>0
Ryosei 27:dd9f27fce7d1 147 Process[0] = Process0;
Ryosei 27:dd9f27fce7d1 148 #endif
Ryosei 27:dd9f27fce7d1 149 #if USE_PROCESS_NUM>1
Ryosei 27:dd9f27fce7d1 150 Process[1] = Process1;
Ryosei 27:dd9f27fce7d1 151 #endif
Ryosei 27:dd9f27fce7d1 152 #if USE_PROCESS_NUM>2
Ryosei 27:dd9f27fce7d1 153 Process[2] = Process2;
Ryosei 27:dd9f27fce7d1 154 #endif
Ryosei 27:dd9f27fce7d1 155 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 156 Process[3] = Process3;
Ryosei 27:dd9f27fce7d1 157 #endif
Ryosei 27:dd9f27fce7d1 158 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 159 Process[4] = Process4;
Ryosei 27:dd9f27fce7d1 160 #endif
Ryosei 27:dd9f27fce7d1 161 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 162 Process[5] = Process5;
Ryosei 27:dd9f27fce7d1 163 #endif
Ryosei 27:dd9f27fce7d1 164 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 165 Process[6] = Process6;
Ryosei 27:dd9f27fce7d1 166 #endif
Ryosei 27:dd9f27fce7d1 167 #if USE_PROCESS_NUM>7
Ryosei 27:dd9f27fce7d1 168 Process[7] = Process7;
Ryosei 27:dd9f27fce7d1 169 #endif
Ryosei 27:dd9f27fce7d1 170 #if USE_PROCESS_NUM>8
Ryosei 27:dd9f27fce7d1 171 Process[8] = Process8;
Ryosei 27:dd9f27fce7d1 172 #endif
Ryosei 27:dd9f27fce7d1 173 #if USE_PROCESS_NUM>9
Ryosei 27:dd9f27fce7d1 174 Process[9] = Process9;
Ryosei 27:dd9f27fce7d1 175 #endif
Ryosei 27:dd9f27fce7d1 176 #endif
t_yamamoto 0:669ef71cba68 177 }
t_yamamoto 0:669ef71cba68 178
t_yamamoto 0:669ef71cba68 179 static void SystemProcessUpdate()
t_yamamoto 0:669ef71cba68 180 {
Ryosei 27:dd9f27fce7d1 181 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 182 if(controller->Button.HOME) lock = false;
Ryosei 27:dd9f27fce7d1 183
Ryosei 27:dd9f27fce7d1 184 if(controller->Button.START && processChangeComp) {
Ryosei 27:dd9f27fce7d1 185 current++;
Ryosei 27:dd9f27fce7d1 186 if (USE_PROCESS_NUM < current) current = USE_PROCESS_NUM;
Ryosei 27:dd9f27fce7d1 187 processChangeComp = false;
Ryosei 27:dd9f27fce7d1 188 } else if(controller->Button.SELECT && processChangeComp) {
Ryosei 27:dd9f27fce7d1 189 current--;
Ryosei 27:dd9f27fce7d1 190 if (current < 0) current = 0;
Ryosei 27:dd9f27fce7d1 191 processChangeComp = false;
Ryosei 27:dd9f27fce7d1 192 } else if(!controller->Button.SELECT && !controller->Button.START) processChangeComp = true;
Ryosei 27:dd9f27fce7d1 193 #endif
Ryosei 27:dd9f27fce7d1 194
Ryosei 27:dd9f27fce7d1 195 #ifdef USE_MOTOR
Ryosei 27:dd9f27fce7d1 196 ACTUATORHUB::MOTOR::Motor::Update(motor);
Ryosei 27:dd9f27fce7d1 197 #endif
Ryosei 27:dd9f27fce7d1 198
Ryosei 27:dd9f27fce7d1 199 #ifdef USE_SOLENOID
Ryosei 27:dd9f27fce7d1 200 ACTUATORHUB::SOLENOID::Solenoid::Update(solenoid);
Ryosei 27:dd9f27fce7d1 201 #endif
Ryosei 27:dd9f27fce7d1 202
Ryosei 27:dd9f27fce7d1 203 #ifdef USE_RS485
Ryosei 27:dd9f27fce7d1 204 ACTUATORHUB::ActuatorHub::Update();
Ryosei 27:dd9f27fce7d1 205 //LINEHUB::LineHub::Update();
Ryosei 27:dd9f27fce7d1 206 #endif
Ryosei 27:dd9f27fce7d1 207
Ryosei 27:dd9f27fce7d1 208 }
Ryosei 27:dd9f27fce7d1 209
yabahiro 39:784552c26163 210 int point1;
Ryosei 27:dd9f27fce7d1 211 void SystemProcess()
Ryosei 27:dd9f27fce7d1 212 {
Ryosei 27:dd9f27fce7d1 213 SystemProcessInitialize();
yabahiro 33:dd598bb23ad1 214
Ryosei 27:dd9f27fce7d1 215 while(1) {
yabahiro 39:784552c26163 216 //pc.printf("4:%d\n\r",g[4]);
yabahiro 46:68296caae1af 217
yabahiro 33:dd598bb23ad1 218 if(EMC==0) {
yabahiro 33:dd598bb23ad1 219 fast=40;
yabahiro 33:dd598bb23ad1 220 normal=30;
yabahiro 33:dd598bb23ad1 221 slow=20;
yabahiro 33:dd598bb23ad1 222 cross=0;//十字数える用
yabahiro 33:dd598bb23ad1 223 cros=0;
yabahiro 33:dd598bb23ad1 224 countss=0;//wait代替え
yabahiro 33:dd598bb23ad1 225 UP_flag = false;
yabahiro 33:dd598bb23ad1 226 SW_flag = false;
yabahiro 33:dd598bb23ad1 227 Air_flag = false;
yabahiro 33:dd598bb23ad1 228 zyouge=false;
yabahiro 33:dd598bb23ad1 229 zyougedo=false;
yabahiro 33:dd598bb23ad1 230 dz2=true;
yabahiro 33:dd598bb23ad1 231 dz2i=false;
yabahiro 33:dd598bb23ad1 232 dz3=true;
yabahiro 33:dd598bb23ad1 233 dz3i=false;
yabahiro 33:dd598bb23ad1 234 dz4=true;
yabahiro 33:dd598bb23ad1 235 dz4i=false;
yabahiro 33:dd598bb23ad1 236 through=false;
yabahiro 33:dd598bb23ad1 237 counts=false;
yabahiro 33:dd598bb23ad1 238 mtc=false;
yabahiro 33:dd598bb23ad1 239 mtc2 = false;
yabahiro 33:dd598bb23ad1 240 current = 0;
yabahiro 33:dd598bb23ad1 241 SystemProcessInitialize();
yabahiro 33:dd598bb23ad1 242 if(emcs==false) {
yabahiro 33:dd598bb23ad1 243 AllActuatorReset();
yabahiro 33:dd598bb23ad1 244 emcs=true;
yabahiro 33:dd598bb23ad1 245 }
yabahiro 33:dd598bb23ad1 246 } else {
yabahiro 33:dd598bb23ad1 247 emcs=false;
yabahiro 33:dd598bb23ad1 248 }
Ryosei 27:dd9f27fce7d1 249
yabahiro 33:dd598bb23ad1 250 if(mode==0) {
yabahiro 33:dd598bb23ad1 251 if(ZoneSW) {
kishibekairohan 35:33c6cdba5630 252 LED::LED::TapeledMode(1);
yabahiro 33:dd598bb23ad1 253 } else {
kishibekairohan 35:33c6cdba5630 254 LED::LED::TapeledMode(2);
yabahiro 33:dd598bb23ad1 255 }
yabahiro 33:dd598bb23ad1 256 }
yabahiro 33:dd598bb23ad1 257 for(int i = 0; i < 8; i++) {
yabahiro 33:dd598bb23ad1 258 g[i] = LineHub::GetPara(i);
yabahiro 33:dd598bb23ad1 259 }
yabahiro 33:dd598bb23ad1 260 if(ThSW) {
yabahiro 33:dd598bb23ad1 261 Twsh=1;
yabahiro 33:dd598bb23ad1 262 } else {
yabahiro 33:dd598bb23ad1 263 Twsh=2;
yabahiro 33:dd598bb23ad1 264 }
yabahiro 33:dd598bb23ad1 265
yabahiro 33:dd598bb23ad1 266 if(StertSW && start_flag == true) {
yabahiro 33:dd598bb23ad1 267 start_flag = false;
yabahiro 33:dd598bb23ad1 268 lock = false;
yabahiro 33:dd598bb23ad1 269 if(ZoneSW) {
yabahiro 33:dd598bb23ad1 270 countss=0;
yabahiro 33:dd598bb23ad1 271 mode=1;
yabahiro 40:ed2409e0ce6b 272 current = 3;//10GATU30変更した
yabahiro 33:dd598bb23ad1 273
yabahiro 33:dd598bb23ad1 274 } else {
kishibekairohan 34:2fce61e3ebc4 275 countss = 0;
yabahiro 33:dd598bb23ad1 276 mode=1;
kishibekairohan 34:2fce61e3ebc4 277 current = 2;
yabahiro 33:dd598bb23ad1 278 }
yabahiro 33:dd598bb23ad1 279 }
yabahiro 33:dd598bb23ad1 280 if(DWSW||DOSW) {
yabahiro 33:dd598bb23ad1 281 if(DWSW) {
yabahiro 33:dd598bb23ad1 282 zyouge=true;
yabahiro 33:dd598bb23ad1 283 }
yabahiro 33:dd598bb23ad1 284 if(DOSW) {
yabahiro 33:dd598bb23ad1 285 if(DOLS) {
yabahiro 33:dd598bb23ad1 286 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 287 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 288 } else {
yabahiro 38:40e7fdf3c694 289 motor[MOTOR_0].pwm = 200;
yabahiro 33:dd598bb23ad1 290 motor[MOTOR_0].dir = BACK;
yabahiro 33:dd598bb23ad1 291 }
yabahiro 33:dd598bb23ad1 292 }
yabahiro 33:dd598bb23ad1 293 } else if(zyouge==false) {
yabahiro 33:dd598bb23ad1 294 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 295 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 296 }
yabahiro 33:dd598bb23ad1 297 if(zyouge) {
yabahiro 33:dd598bb23ad1 298 if(Twsh==1) {
yabahiro 38:40e7fdf3c694 299 motor[MOTOR_0].pwm = 255;
yabahiro 33:dd598bb23ad1 300 motor[MOTOR_0].dir = FOR;
yabahiro 33:dd598bb23ad1 301 if(UPLS) {
yabahiro 33:dd598bb23ad1 302 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 303 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 304 zyouge=false;
yabahiro 33:dd598bb23ad1 305 }
yabahiro 33:dd598bb23ad1 306 }
yabahiro 33:dd598bb23ad1 307 if(Twsh==2) {
yabahiro 33:dd598bb23ad1 308 motor[MOTOR_0].pwm = 245;
yabahiro 33:dd598bb23ad1 309 motor[MOTOR_0].dir = FOR;
yabahiro 33:dd598bb23ad1 310 if(UPLS2) {
yabahiro 33:dd598bb23ad1 311 motor[MOTOR_0].pwm = 100;
yabahiro 33:dd598bb23ad1 312 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 313 zyouge=false;
yabahiro 33:dd598bb23ad1 314 }
yabahiro 33:dd598bb23ad1 315 }
yabahiro 33:dd598bb23ad1 316 }
yabahiro 33:dd598bb23ad1 317 if(AIRSW) {
yabahiro 33:dd598bb23ad1 318 if(SW_flag==false) {
yabahiro 33:dd598bb23ad1 319 if(Air_flag==false) {
yabahiro 33:dd598bb23ad1 320 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 321 Air_flag=true;
yabahiro 33:dd598bb23ad1 322 SW_flag=true;
yabahiro 33:dd598bb23ad1 323 } else {
yabahiro 33:dd598bb23ad1 324 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 325 Air_flag=false;
yabahiro 33:dd598bb23ad1 326 SW_flag=true;
yabahiro 33:dd598bb23ad1 327 }
yabahiro 33:dd598bb23ad1 328 }
yabahiro 33:dd598bb23ad1 329 } else {
yabahiro 33:dd598bb23ad1 330 if(SW_flag==true) {
yabahiro 33:dd598bb23ad1 331 countss++;
yabahiro 33:dd598bb23ad1 332 if(countss>=2000) {
yabahiro 33:dd598bb23ad1 333 SW_flag=false;
yabahiro 33:dd598bb23ad1 334 countss=0;
yabahiro 33:dd598bb23ad1 335 }
yabahiro 33:dd598bb23ad1 336 }
yabahiro 33:dd598bb23ad1 337 }
yabahiro 33:dd598bb23ad1 338
yabahiro 33:dd598bb23ad1 339
yabahiro 33:dd598bb23ad1 340 #ifdef USE_MU
Ryosei 27:dd9f27fce7d1 341 controller = CONTROLLER::Controller::GetData();
yabahiro 33:dd598bb23ad1 342 #endif
yabahiro 33:dd598bb23ad1 343
Ryosei 27:dd9f27fce7d1 344
yabahiro 33:dd598bb23ad1 345 #ifdef USE_ERRORCHECK
yabahiro 38:40e7fdf3c694 346 if(SAFTY::ErrorCheck::Check() & SAFTY::Error::ControllerLost & start_flag) {
Ryosei 27:dd9f27fce7d1 347 CONTROLLER::Controller::DataReset();
Ryosei 27:dd9f27fce7d1 348 AllActuatorReset();
Ryosei 27:dd9f27fce7d1 349 lock = true;
Ryosei 27:dd9f27fce7d1 350 } else
yabahiro 38:40e7fdf3c694 351
yabahiro 33:dd598bb23ad1 352 #endif
Ryosei 27:dd9f27fce7d1 353 {
Ryosei 27:dd9f27fce7d1 354
yabahiro 33:dd598bb23ad1 355 #ifdef USE_SUBPROCESS
Ryosei 27:dd9f27fce7d1 356 if(!lock) {
Ryosei 27:dd9f27fce7d1 357 Process[current]();
Ryosei 27:dd9f27fce7d1 358 } else
yabahiro 33:dd598bb23ad1 359 #endif
Ryosei 27:dd9f27fce7d1 360 {
Ryosei 27:dd9f27fce7d1 361 //ロック時の処理
Ryosei 27:dd9f27fce7d1 362 }
Ryosei 27:dd9f27fce7d1 363 }
yabahiro 33:dd598bb23ad1 364
Ryosei 27:dd9f27fce7d1 365 SystemProcessUpdate();
Ryosei 27:dd9f27fce7d1 366 }
t_yamamoto 0:669ef71cba68 367 }
t_yamamoto 0:669ef71cba68 368
kishibekairohan 2:c015739085d3 369
kishibekairohan 2:c015739085d3 370
kishibekairohan 2:c015739085d3 371
t_yamamoto 0:669ef71cba68 372 #pragma region PROCESS
t_yamamoto 0:669ef71cba68 373 #ifdef USE_SUBPROCESS
t_yamamoto 0:669ef71cba68 374 #if USE_PROCESS_NUM>0
Ryosei 27:dd9f27fce7d1 375 static void Process0()
Ryosei 27:dd9f27fce7d1 376 {
yabahiro 33:dd598bb23ad1 377
yabahiro 33:dd598bb23ad1 378 //AllActuatorReset();
t_yamamoto 0:669ef71cba68 379 }
t_yamamoto 0:669ef71cba68 380 #endif
t_yamamoto 0:669ef71cba68 381
t_yamamoto 0:669ef71cba68 382 #if USE_PROCESS_NUM>1
kishibekairohan 16:3f2c2d89372b 383 static void Process1()
t_yamamoto 0:669ef71cba68 384 {
kishibekairohan 35:33c6cdba5630 385 LED::LED::TapeledMode(6);
yabahiro 33:dd598bb23ad1 386 start_flag = true;
yabahiro 33:dd598bb23ad1 387 mtc=false;
yabahiro 33:dd598bb23ad1 388 mtc2 = false;
yabahiro 33:dd598bb23ad1 389 mode=1;
yabahiro 33:dd598bb23ad1 390 cross=0;
yabahiro 33:dd598bb23ad1 391 Twsh=1;
yabahiro 33:dd598bb23ad1 392 motor[TIRE_FR].dir = SetStatus(-omni[controller->AnalogL.Y][14-controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 33:dd598bb23ad1 393 motor[TIRE_FL].dir = SetStatus(omni[controller->AnalogL.Y][controller->AnalogL.X] + curve[controller->AnalogR.X]);
yabahiro 33:dd598bb23ad1 394 motor[TIRE_BR].dir = SetStatus(-omni[14-controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
yabahiro 33:dd598bb23ad1 395 motor[TIRE_BL].dir = SetStatus(omni[controller->AnalogL.X][14-controller->AnalogL.Y] + curve[controller->AnalogR.X]);
Ryosei 27:dd9f27fce7d1 396
kishibekairohan 42:980af34f6fe3 397 motor[TIRE_FR].pwm = SetPWM(omni[controller->AnalogL.Y][14-controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
kishibekairohan 42:980af34f6fe3 398 motor[TIRE_FL].pwm = SetPWM(omni[controller->AnalogL.Y][controller->AnalogL.X]+ curve[controller->AnalogR.X])*0.2;
kishibekairohan 42:980af34f6fe3 399 motor[TIRE_BR].pwm = SetPWM(omni[14-controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
kishibekairohan 42:980af34f6fe3 400 motor[TIRE_BL].pwm = SetPWM(omni[controller->AnalogL.X][14-controller->AnalogL.Y]+ curve[controller->AnalogR.X])*0.2;
yabahiro 33:dd598bb23ad1 401
yabahiro 33:dd598bb23ad1 402 if(controller->Button.UP||controller->Button.DOWN) {
yabahiro 33:dd598bb23ad1 403
yabahiro 33:dd598bb23ad1 404 if(controller->Button.UP) {
yabahiro 33:dd598bb23ad1 405 motor[MOTOR_0].pwm =200;
yabahiro 33:dd598bb23ad1 406 motor[MOTOR_0].dir = FOR;
yabahiro 33:dd598bb23ad1 407 if(UPLS) {
yabahiro 33:dd598bb23ad1 408 motor[MOTOR_0].pwm = 0;
yabahiro 33:dd598bb23ad1 409 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 410 }
yabahiro 33:dd598bb23ad1 411 }
yabahiro 33:dd598bb23ad1 412 if(controller->Button.DOWN) {
yabahiro 33:dd598bb23ad1 413 motor[MOTOR_0].pwm = 50;
yabahiro 33:dd598bb23ad1 414 motor[MOTOR_0].dir = BACK;
yabahiro 33:dd598bb23ad1 415 }
yabahiro 33:dd598bb23ad1 416 } else {
yabahiro 33:dd598bb23ad1 417 motor[MOTOR_0].pwm = 0;
yabahiro 33:dd598bb23ad1 418 motor[MOTOR_0].dir = BRAKE;
yabahiro 33:dd598bb23ad1 419 }
yabahiro 33:dd598bb23ad1 420
yabahiro 33:dd598bb23ad1 421 if(controller->Button.Y) {
yabahiro 33:dd598bb23ad1 422 if(dz2==true) {
yabahiro 33:dd598bb23ad1 423 if(dz2i==false) {
yabahiro 33:dd598bb23ad1 424 solenoid.solenoid2 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 425 dz2i=true;
yabahiro 33:dd598bb23ad1 426 } else {
yabahiro 33:dd598bb23ad1 427 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 428 dz2i=false;
yabahiro 33:dd598bb23ad1 429 }
yabahiro 33:dd598bb23ad1 430 dz2=false;
yabahiro 33:dd598bb23ad1 431 }
yabahiro 33:dd598bb23ad1 432 } else {
yabahiro 33:dd598bb23ad1 433 dz2=true;
yabahiro 33:dd598bb23ad1 434 }
yabahiro 33:dd598bb23ad1 435
yabahiro 33:dd598bb23ad1 436 if(controller->Button.A) {
yabahiro 33:dd598bb23ad1 437 if(dz3==true) {
yabahiro 33:dd598bb23ad1 438 if(dz3i==false) {
kishibekairohan 37:e77816810627 439 solenoid.solenoid3 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 440 dz3i=true;
yabahiro 33:dd598bb23ad1 441 } else {
yabahiro 33:dd598bb23ad1 442 solenoid.solenoid3 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 443 dz3i=false;
yabahiro 33:dd598bb23ad1 444 }
yabahiro 33:dd598bb23ad1 445 dz3=false;
yabahiro 33:dd598bb23ad1 446 }
yabahiro 33:dd598bb23ad1 447 } else {
yabahiro 33:dd598bb23ad1 448 dz3=true;
yabahiro 33:dd598bb23ad1 449 }
yabahiro 33:dd598bb23ad1 450
yabahiro 33:dd598bb23ad1 451 if(controller->Button.B) {
yabahiro 33:dd598bb23ad1 452 if(dz4==true) {
yabahiro 33:dd598bb23ad1 453 if(dz4i==false) {
yabahiro 38:40e7fdf3c694 454 solenoid.solenoid4 = SOLENOID_ON;
yabahiro 33:dd598bb23ad1 455 dz4i=true;
yabahiro 33:dd598bb23ad1 456 } else {
yabahiro 38:40e7fdf3c694 457 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 458 dz4i=false;
yabahiro 33:dd598bb23ad1 459 }
yabahiro 33:dd598bb23ad1 460 dz4=false;
yabahiro 33:dd598bb23ad1 461 }
yabahiro 33:dd598bb23ad1 462 } else {
yabahiro 33:dd598bb23ad1 463 dz4=true;
yabahiro 33:dd598bb23ad1 464 }
t_yamamoto 0:669ef71cba68 465 }
t_yamamoto 0:669ef71cba68 466 #endif
t_yamamoto 0:669ef71cba68 467
t_yamamoto 0:669ef71cba68 468 #if USE_PROCESS_NUM>2
kishibekairohan 16:3f2c2d89372b 469 static void Process2()
Ryosei 27:dd9f27fce7d1 470 {
yabahiro 33:dd598bb23ad1 471 //Oh So 青ゾーン
yabahiro 39:784552c26163 472 LED::LED::TapeledMode(2);
yabahiro 33:dd598bb23ad1 473 countss++;
yabahiro 33:dd598bb23ad1 474 if(mode==1) {//スタートゾーンから白線検知
yabahiro 33:dd598bb23ad1 475 fast=40;
yabahiro 33:dd598bb23ad1 476 normal=30;
yabahiro 33:dd598bb23ad1 477 slow=20;
kishibekairohan 45:0cf48a0605cd 478 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 479 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 480 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 481 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 482 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 483 motor[TIRE_BR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 484 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 485 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 486 if(g[2]==0&&countss>=100000) {
yabahiro 33:dd598bb23ad1 487 countss=100000;
yabahiro 33:dd598bb23ad1 488 cross=0;
yabahiro 33:dd598bb23ad1 489 mode=3;
yabahiro 33:dd598bb23ad1 490 }
yabahiro 46:68296caae1af 491 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 33:dd598bb23ad1 492 motor[TIRE_FR].pwm = 30;
yabahiro 33:dd598bb23ad1 493 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 494 motor[TIRE_FL].pwm = 255;
kishibekairohan 45:0cf48a0605cd 495 motor[TIRE_FL].dir = BRAKE;
kishibekairohan 45:0cf48a0605cd 496 motor[TIRE_BR].pwm = 255;
kishibekairohan 45:0cf48a0605cd 497 motor[TIRE_BR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 498 motor[TIRE_BL].pwm = 30;
yabahiro 33:dd598bb23ad1 499 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 500 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 501 mode=10;
yabahiro 33:dd598bb23ad1 502 countss=100000;
yabahiro 33:dd598bb23ad1 503 }
yabahiro 46:68296caae1af 504 } else if(mode==10) { //縦ライントレース
yabahiro 33:dd598bb23ad1 505 switch(g[1]) {
yabahiro 33:dd598bb23ad1 506 case 98:
kishibekairohan 45:0cf48a0605cd 507 motor[TIRE_FR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 508 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 509 motor[TIRE_FL].pwm = normal+50;
yabahiro 33:dd598bb23ad1 510 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 511 motor[TIRE_BR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 512 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 513 motor[TIRE_BL].pwm = normal+45;
yabahiro 33:dd598bb23ad1 514 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 515 mtc=true;
yabahiro 39:784552c26163 516 if(countss>80000) {
yabahiro 33:dd598bb23ad1 517 cross++;
yabahiro 33:dd598bb23ad1 518 countss=0;
yabahiro 33:dd598bb23ad1 519 }
yabahiro 46:68296caae1af 520
yabahiro 46:68296caae1af 521 if(cross==2) {
yabahiro 46:68296caae1af 522 fast = 10;
yabahiro 46:68296caae1af 523 normal = 10;
kishibekairohan 45:0cf48a0605cd 524 slow = 5;
kishibekairohan 45:0cf48a0605cd 525 }
yabahiro 46:68296caae1af 526
yabahiro 39:784552c26163 527 if(cross==3) {
kishibekairohan 45:0cf48a0605cd 528 fast=40;
kishibekairohan 45:0cf48a0605cd 529 normal=30;
kishibekairohan 45:0cf48a0605cd 530 slow=20;
yabahiro 33:dd598bb23ad1 531 mode=11;
yabahiro 33:dd598bb23ad1 532 countss=0;
yabahiro 33:dd598bb23ad1 533 cross=0;
yabahiro 33:dd598bb23ad1 534 }
yabahiro 33:dd598bb23ad1 535 break;
yabahiro 33:dd598bb23ad1 536 case 0:
kishibekairohan 45:0cf48a0605cd 537 motor[TIRE_FR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 538 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 539 motor[TIRE_FL].pwm = fast+50;
yabahiro 33:dd598bb23ad1 540 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 541 motor[TIRE_BR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 542 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 543 motor[TIRE_BL].pwm = fast+45;
yabahiro 33:dd598bb23ad1 544 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 545 mtc=true;
yabahiro 33:dd598bb23ad1 546 break;
yabahiro 33:dd598bb23ad1 547 case 255:
kishibekairohan 45:0cf48a0605cd 548 motor[TIRE_FR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 549 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 550 motor[TIRE_FL].pwm = slow+50;
yabahiro 33:dd598bb23ad1 551 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 552 motor[TIRE_BR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 553 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 554 motor[TIRE_BL].pwm = fast+45;
yabahiro 33:dd598bb23ad1 555 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 556 mtc=true;
yabahiro 33:dd598bb23ad1 557 break;
yabahiro 33:dd598bb23ad1 558 case 253:
kishibekairohan 45:0cf48a0605cd 559 motor[TIRE_FR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 560 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 561 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 562 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 563 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 564 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 565 motor[TIRE_BL].pwm = slow+45;
yabahiro 33:dd598bb23ad1 566 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 567 mtc=true;
yabahiro 33:dd598bb23ad1 568 break;
yabahiro 33:dd598bb23ad1 569 case 254:
kishibekairohan 45:0cf48a0605cd 570 motor[TIRE_FR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 571 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 572 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 573 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 574 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 575 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 576 motor[TIRE_BL].pwm = normal+45;
yabahiro 33:dd598bb23ad1 577 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 578 mtc=true;
yabahiro 33:dd598bb23ad1 579 break;
yabahiro 33:dd598bb23ad1 580 case 1:
kishibekairohan 45:0cf48a0605cd 581 motor[TIRE_FR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 582 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 583 motor[TIRE_FL].pwm = fast+50;
yabahiro 33:dd598bb23ad1 584 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 585 motor[TIRE_BR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 586 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 587 motor[TIRE_BL].pwm = slow+45;
yabahiro 33:dd598bb23ad1 588 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 589 mtc=true;
yabahiro 33:dd598bb23ad1 590 break;
yabahiro 33:dd598bb23ad1 591 case 3:
yabahiro 33:dd598bb23ad1 592 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 593 motor[TIRE_FR].dir = FREE;
kishibekairohan 45:0cf48a0605cd 594 motor[TIRE_FL].pwm = slow+50;
yabahiro 33:dd598bb23ad1 595 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 596 motor[TIRE_BR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 597 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 598 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 599 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 600 mtc=true;
yabahiro 33:dd598bb23ad1 601 break;
yabahiro 33:dd598bb23ad1 602 case 2:
yabahiro 33:dd598bb23ad1 603 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 604 motor[TIRE_FR].dir = FREE;
kishibekairohan 45:0cf48a0605cd 605 motor[TIRE_FL].pwm = normal+50;
yabahiro 33:dd598bb23ad1 606 motor[TIRE_FL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 607 motor[TIRE_BR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 608 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 609 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 610 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 611 mtc=true;
yabahiro 33:dd598bb23ad1 612 break;
yabahiro 33:dd598bb23ad1 613 }
kishibekairohan 45:0cf48a0605cd 614 if(g[1]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 615 switch(g[0]) {
yabahiro 33:dd598bb23ad1 616 case 0:
yabahiro 33:dd598bb23ad1 617 mtc=false;
yabahiro 33:dd598bb23ad1 618 break;
yabahiro 33:dd598bb23ad1 619 case 255:
kishibekairohan 45:0cf48a0605cd 620 motor[TIRE_FL].pwm += 3;
yabahiro 33:dd598bb23ad1 621 mtc=false;
yabahiro 33:dd598bb23ad1 622 break;
yabahiro 33:dd598bb23ad1 623 case 253:
kishibekairohan 45:0cf48a0605cd 624 motor[TIRE_FL].pwm += 6;
yabahiro 33:dd598bb23ad1 625 mtc=false;
yabahiro 33:dd598bb23ad1 626 break;
yabahiro 33:dd598bb23ad1 627 case 254:
kishibekairohan 45:0cf48a0605cd 628 motor[TIRE_FL].pwm += 9;
yabahiro 33:dd598bb23ad1 629 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 630 mtc=false;
yabahiro 33:dd598bb23ad1 631 break;
yabahiro 33:dd598bb23ad1 632 case 1:
kishibekairohan 45:0cf48a0605cd 633 motor[TIRE_FR].pwm += 3;
yabahiro 33:dd598bb23ad1 634 mtc=false;
yabahiro 33:dd598bb23ad1 635 break;
yabahiro 33:dd598bb23ad1 636 case 3:
kishibekairohan 45:0cf48a0605cd 637 motor[TIRE_FR].pwm += 6;
yabahiro 33:dd598bb23ad1 638 mtc=false;
yabahiro 33:dd598bb23ad1 639 break;
yabahiro 33:dd598bb23ad1 640 case 2:
kishibekairohan 45:0cf48a0605cd 641 motor[TIRE_FR].pwm += 9;
yabahiro 33:dd598bb23ad1 642 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 643 mtc=false;
yabahiro 33:dd598bb23ad1 644 break;
yabahiro 33:dd598bb23ad1 645 }
yabahiro 33:dd598bb23ad1 646 }
yabahiro 33:dd598bb23ad1 647 } else if(mode==11) {
yabahiro 33:dd598bb23ad1 648 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 649 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 650 motor[TIRE_FL].pwm = 50;
yabahiro 48:5562a99479e5 651 motor[TIRE_FL].dir = BRAKE;
yabahiro 48:5562a99479e5 652 motor[TIRE_BR].pwm = 50;
yabahiro 48:5562a99479e5 653 motor[TIRE_BR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 654 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 655 motor[TIRE_BL].dir = BACK;
kishibekairohan 45:0cf48a0605cd 656 if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) {
yabahiro 33:dd598bb23ad1 657 countss=0;
yabahiro 33:dd598bb23ad1 658 cross=0;
yabahiro 33:dd598bb23ad1 659 mode=20;
yabahiro 33:dd598bb23ad1 660 }
yabahiro 46:68296caae1af 661 } else if(mode==20) {
yabahiro 48:5562a99479e5 662 solenoid.solenoid2= SOLENOID_ON;
yabahiro 33:dd598bb23ad1 663 switch(g[2]) {
yabahiro 33:dd598bb23ad1 664 case 98:
yabahiro 48:5562a99479e5 665 motor[TIRE_FR].pwm = normal-20;
yabahiro 33:dd598bb23ad1 666 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 667 motor[TIRE_FL].pwm = normal-20;
yabahiro 33:dd598bb23ad1 668 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 669 motor[TIRE_BR].pwm = normal-20;
yabahiro 33:dd598bb23ad1 670 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 671 motor[TIRE_BL].pwm = normal-20;
yabahiro 33:dd598bb23ad1 672 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 673 if(countss>10000) {
yabahiro 33:dd598bb23ad1 674 cross++;
yabahiro 33:dd598bb23ad1 675 countss=0;
yabahiro 33:dd598bb23ad1 676 }
yabahiro 33:dd598bb23ad1 677 mtc2=true;
yabahiro 46:68296caae1af 678
kishibekairohan 45:0cf48a0605cd 679 if(YELLOW) {
kishibekairohan 45:0cf48a0605cd 680 if(cross==1) {
kishibekairohan 47:a9cad8502999 681 fast=20;
kishibekairohan 47:a9cad8502999 682 normal=15;
kishibekairohan 47:a9cad8502999 683 slow=15;
yabahiro 46:68296caae1af 684 } else if(cross==2) {
yabahiro 39:784552c26163 685 mode=21;
yabahiro 39:784552c26163 686 countss=0;
yabahiro 39:784552c26163 687 cross=0;
yabahiro 39:784552c26163 688 }
yabahiro 39:784552c26163 689 } else {
kishibekairohan 45:0cf48a0605cd 690 if(cross==3) {
yabahiro 39:784552c26163 691 mode=21;
yabahiro 39:784552c26163 692 countss=0;
yabahiro 39:784552c26163 693 cross=0;
yabahiro 39:784552c26163 694 }
yabahiro 39:784552c26163 695 }
yabahiro 33:dd598bb23ad1 696 break;
yabahiro 33:dd598bb23ad1 697 case 0:
kishibekairohan 45:0cf48a0605cd 698 motor[TIRE_FR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 699 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 700 motor[TIRE_FL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 701 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 702 motor[TIRE_BR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 703 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 704 motor[TIRE_BL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 705 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 706 mtc2=true;
yabahiro 33:dd598bb23ad1 707 break;
yabahiro 33:dd598bb23ad1 708 case 255:
kishibekairohan 45:0cf48a0605cd 709 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 710 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 711 motor[TIRE_FL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 712 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 713 motor[TIRE_BR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 714 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 715 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 716 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 717 mtc2=true;
yabahiro 33:dd598bb23ad1 718 break;
yabahiro 33:dd598bb23ad1 719 case 253:
yabahiro 33:dd598bb23ad1 720 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 721 motor[TIRE_FR].dir = FREE;
kishibekairohan 45:0cf48a0605cd 722 motor[TIRE_FL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 723 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 724 motor[TIRE_BR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 725 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 726 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 727 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 728 mtc2=true;
yabahiro 33:dd598bb23ad1 729 break;
yabahiro 33:dd598bb23ad1 730 case 254:
yabahiro 33:dd598bb23ad1 731 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 732 motor[TIRE_FR].dir = FREE;
kishibekairohan 45:0cf48a0605cd 733 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 734 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 735 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 736 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 737 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 738 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 739 mtc2=true;
yabahiro 33:dd598bb23ad1 740 break;
yabahiro 33:dd598bb23ad1 741 case 1:
kishibekairohan 45:0cf48a0605cd 742 motor[TIRE_FR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 743 motor[TIRE_FR].dir = FOR;
kishibekairohan 45:0cf48a0605cd 744 motor[TIRE_FL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 745 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 746 motor[TIRE_BR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 747 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 748 motor[TIRE_BL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 749 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 750 mtc2=true;
yabahiro 33:dd598bb23ad1 751 break;
yabahiro 33:dd598bb23ad1 752 case 3:
kishibekairohan 45:0cf48a0605cd 753 motor[TIRE_FR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 754 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 755 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 756 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 757 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 758 motor[TIRE_BR].dir = FREE;
kishibekairohan 45:0cf48a0605cd 759 motor[TIRE_BL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 760 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 761 mtc2=true;
yabahiro 33:dd598bb23ad1 762 break;
yabahiro 33:dd598bb23ad1 763 case 2:
kishibekairohan 45:0cf48a0605cd 764 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 765 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 766 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 767 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 768 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 769 motor[TIRE_BR].dir = FREE;
kishibekairohan 45:0cf48a0605cd 770 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 771 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 772 mtc2=true;
yabahiro 33:dd598bb23ad1 773 break;
yabahiro 33:dd598bb23ad1 774 }
yabahiro 33:dd598bb23ad1 775 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 776 switch(g[3]) {
yabahiro 33:dd598bb23ad1 777 case 0:
yabahiro 33:dd598bb23ad1 778 mtc2=false;
yabahiro 33:dd598bb23ad1 779 break;
yabahiro 33:dd598bb23ad1 780 case 255:
yabahiro 33:dd598bb23ad1 781 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 782 mtc2=false;
yabahiro 33:dd598bb23ad1 783 break;
yabahiro 33:dd598bb23ad1 784 case 253:
yabahiro 33:dd598bb23ad1 785 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 786 mtc2=false;
yabahiro 33:dd598bb23ad1 787 break;
yabahiro 33:dd598bb23ad1 788 case 254:
kishibekairohan 45:0cf48a0605cd 789 motor[TIRE_BL].pwm += 15;
yabahiro 33:dd598bb23ad1 790 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 791 mtc2=false;
yabahiro 33:dd598bb23ad1 792 break;
yabahiro 33:dd598bb23ad1 793 case 1:
yabahiro 33:dd598bb23ad1 794 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 795 mtc2=false;
yabahiro 33:dd598bb23ad1 796 break;
yabahiro 33:dd598bb23ad1 797 case 3:
yabahiro 33:dd598bb23ad1 798 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 799 mtc2=false;
yabahiro 33:dd598bb23ad1 800 break;
yabahiro 33:dd598bb23ad1 801 case 2:
kishibekairohan 45:0cf48a0605cd 802 motor[TIRE_FL].pwm += 15;
yabahiro 33:dd598bb23ad1 803 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 804 mtc2=false;
yabahiro 33:dd598bb23ad1 805 break;
yabahiro 33:dd598bb23ad1 806 }
yabahiro 33:dd598bb23ad1 807 }
yabahiro 33:dd598bb23ad1 808 }
yabahiro 39:784552c26163 809 if(YELLOW) {
yabahiro 39:784552c26163 810 if(mode==21) {
yabahiro 33:dd598bb23ad1 811 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 812 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 813 motor[TIRE_FL].pwm = 20;
yabahiro 33:dd598bb23ad1 814 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 815 motor[TIRE_BR].pwm = 20;
yabahiro 33:dd598bb23ad1 816 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 817 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 818 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 819 if(g[3]==98&&countss>=10000) {
yabahiro 39:784552c26163 820 mode=22;
yabahiro 33:dd598bb23ad1 821 countss=0;
yabahiro 39:784552c26163 822 fast=60;
yabahiro 39:784552c26163 823 normal=40;
yabahiro 39:784552c26163 824 slow=20;
yabahiro 39:784552c26163 825 }
yabahiro 46:68296caae1af 826 } else if(mode==22) {
yabahiro 39:784552c26163 827 if(g[4]==3||g[4]==2) {
yabahiro 39:784552c26163 828 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 829 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 830 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 831 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 832 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 833 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 834 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 835 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 836 }
yabahiro 39:784552c26163 837 if(g[4]==253||g[4]==254) {
yabahiro 39:784552c26163 838 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 839 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 840 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 841 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 842 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 843 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 844 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 845 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 846 }
yabahiro 39:784552c26163 847 switch(g[2]) {
yabahiro 39:784552c26163 848 case 0:
yabahiro 39:784552c26163 849 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 850 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 851 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 852 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 853 break;
yabahiro 39:784552c26163 854 case 255:
yabahiro 39:784552c26163 855 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 856 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 857 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 858 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 859 break;
yabahiro 39:784552c26163 860 case 253:
yabahiro 39:784552c26163 861 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 862 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 863 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 864 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 865 break;
yabahiro 39:784552c26163 866 case 254:
yabahiro 39:784552c26163 867 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 868 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 869 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 870 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 871 break;
yabahiro 39:784552c26163 872 case 1:
yabahiro 39:784552c26163 873 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 874 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 875 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 876 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 877 break;
yabahiro 39:784552c26163 878 case 3:
yabahiro 39:784552c26163 879 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 880 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 881 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 882 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 883 break;
yabahiro 39:784552c26163 884 case 2:
yabahiro 39:784552c26163 885 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 886 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 887 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 888 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 889 break;
yabahiro 39:784552c26163 890 }
yabahiro 39:784552c26163 891 switch(g[3]) {
yabahiro 39:784552c26163 892 case 0:
yabahiro 39:784552c26163 893 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 894 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 895 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 896 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 897 break;
yabahiro 39:784552c26163 898 case 255:
yabahiro 39:784552c26163 899 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 900 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 901 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 902 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 903 case 253:
yabahiro 39:784552c26163 904 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 905 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 906 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 907 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 908 break;
yabahiro 39:784552c26163 909 case 254:
yabahiro 39:784552c26163 910 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 911 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 912 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 913 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 914 break;
yabahiro 39:784552c26163 915 case 1:
yabahiro 39:784552c26163 916 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 917 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 918 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 919 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 920 break;
yabahiro 39:784552c26163 921 case 3:
yabahiro 39:784552c26163 922 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 923 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 924 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 925 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 926 break;
yabahiro 39:784552c26163 927 case 2:
yabahiro 39:784552c26163 928 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 929 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 930 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 931 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 932 break;
yabahiro 39:784552c26163 933 }
yabahiro 39:784552c26163 934 if(g[3]==0&&g[2]==0) {
yabahiro 39:784552c26163 935 mode=23;
yabahiro 33:dd598bb23ad1 936 countss=0;
yabahiro 33:dd598bb23ad1 937 }
yabahiro 46:68296caae1af 938 } else if(mode==23) {
yabahiro 39:784552c26163 939 switch(g[4]) {
yabahiro 39:784552c26163 940 case 98:
kishibekairohan 45:0cf48a0605cd 941 motor[TIRE_FR].pwm = fast-5;
yabahiro 39:784552c26163 942 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 943 motor[TIRE_FL].pwm = fast-5;
yabahiro 39:784552c26163 944 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 945 motor[TIRE_BR].pwm = fast-5;
yabahiro 39:784552c26163 946 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 947 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 948 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 949 break;
yabahiro 39:784552c26163 950 case 99:
yabahiro 39:784552c26163 951 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 952 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 953 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 954 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 955 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 956 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 957 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 958 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 959 break;
yabahiro 39:784552c26163 960 case 0:
kishibekairohan 45:0cf48a0605cd 961 motor[TIRE_FR].pwm = fast-5;
yabahiro 39:784552c26163 962 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 963 motor[TIRE_FL].pwm = fast-5;
yabahiro 39:784552c26163 964 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 965 motor[TIRE_BR].pwm = fast-5;
yabahiro 39:784552c26163 966 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 967 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 968 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 969 break;
yabahiro 39:784552c26163 970 case 255:
yabahiro 39:784552c26163 971 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 972 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 973 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 974 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 975 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 976 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 977 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 978 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 979 break;
yabahiro 39:784552c26163 980 case 253:
kishibekairohan 45:0cf48a0605cd 981 motor[TIRE_FR].pwm = fast-5;
yabahiro 39:784552c26163 982 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 983 motor[TIRE_FL].pwm = slow-5;
yabahiro 39:784552c26163 984 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 985 motor[TIRE_BR].pwm = slow-5;
yabahiro 39:784552c26163 986 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 987 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 988 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 989 break;
yabahiro 39:784552c26163 990 case 254:
kishibekairohan 45:0cf48a0605cd 991 motor[TIRE_FR].pwm = fast-5;
yabahiro 39:784552c26163 992 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 993 motor[TIRE_FL].pwm = normal-5;
yabahiro 39:784552c26163 994 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 995 motor[TIRE_BR].pwm = normal-5;
yabahiro 39:784552c26163 996 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 997 motor[TIRE_BL].pwm = fast-5;
yabahiro 39:784552c26163 998 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 999 break;
yabahiro 39:784552c26163 1000 case 1:
yabahiro 39:784552c26163 1001 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1002 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1003 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1004 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1005 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1006 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1007 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1008 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1009 break;
yabahiro 39:784552c26163 1010 case 3:
kishibekairohan 45:0cf48a0605cd 1011 motor[TIRE_FR].pwm = slow-5;
yabahiro 39:784552c26163 1012 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1013 motor[TIRE_FL].pwm = fast-5;
yabahiro 39:784552c26163 1014 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1015 motor[TIRE_BR].pwm = fast-5;
yabahiro 39:784552c26163 1016 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1017 motor[TIRE_BL].pwm = slow-5;
yabahiro 39:784552c26163 1018 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1019 break;
yabahiro 39:784552c26163 1020 case 2:
kishibekairohan 45:0cf48a0605cd 1021 motor[TIRE_FR].pwm = normal-5;
yabahiro 39:784552c26163 1022 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1023 motor[TIRE_FL].pwm = fast-5;
yabahiro 39:784552c26163 1024 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1025 motor[TIRE_BR].pwm = fast-5;
yabahiro 39:784552c26163 1026 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1027 motor[TIRE_BL].pwm = normal-5;
yabahiro 39:784552c26163 1028 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1029 break;
yabahiro 39:784552c26163 1030 }
yabahiro 39:784552c26163 1031 if(g[2]==254&&countss>=100000) {
yabahiro 39:784552c26163 1032 mode=24;
yabahiro 48:5562a99479e5 1033 solenoid.solenoid2 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 1034 countss=0;
yabahiro 39:784552c26163 1035 fast=60;
yabahiro 39:784552c26163 1036 normal=40;
kishibekairohan 45:0cf48a0605cd 1037 slow=20;
yabahiro 39:784552c26163 1038 }
yabahiro 46:68296caae1af 1039 } else if(mode==24) {
yabahiro 39:784552c26163 1040 if(g[4]==3||g[4]==2) {
yabahiro 39:784552c26163 1041 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1042 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1043 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1044 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1045 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1046 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1047 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1048 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1049 }
yabahiro 39:784552c26163 1050 if(g[4]==253||g[4]==254) {
yabahiro 39:784552c26163 1051 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1052 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1053 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1054 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 1055 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1056 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1057 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1058 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1059 }
yabahiro 39:784552c26163 1060 switch(g[2]) {
yabahiro 39:784552c26163 1061 case 0:
yabahiro 39:784552c26163 1062 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1063 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1064 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1065 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1066 break;
yabahiro 39:784552c26163 1067 case 255:
yabahiro 39:784552c26163 1068 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1069 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1070 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1071 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1072 break;
yabahiro 39:784552c26163 1073 case 253:
yabahiro 39:784552c26163 1074 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 1075 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1076 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1077 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1078 break;
yabahiro 39:784552c26163 1079 case 254:
yabahiro 39:784552c26163 1080 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1081 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1082 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1083 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1084 break;
yabahiro 39:784552c26163 1085 case 1:
yabahiro 39:784552c26163 1086 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1087 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1088 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1089 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1090 break;
yabahiro 39:784552c26163 1091 case 3:
yabahiro 39:784552c26163 1092 motor[TIRE_FR].pwm = 20;
yabahiro 39:784552c26163 1093 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1094 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 1095 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1096 break;
yabahiro 39:784552c26163 1097 case 2:
yabahiro 39:784552c26163 1098 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1099 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1100 motor[TIRE_BR].pwm = 30;
yabahiro 39:784552c26163 1101 motor[TIRE_BR].dir = FOR;
yabahiro 39:784552c26163 1102 break;
yabahiro 39:784552c26163 1103 }
yabahiro 39:784552c26163 1104 switch(g[3]) {
yabahiro 39:784552c26163 1105 case 0:
yabahiro 39:784552c26163 1106 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1107 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1108 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1109 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1110 break;
yabahiro 39:784552c26163 1111 case 255:
yabahiro 39:784552c26163 1112 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1113 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1114 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1115 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1116 case 253:
yabahiro 39:784552c26163 1117 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1118 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1119 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 1120 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1121 break;
yabahiro 39:784552c26163 1122 case 254:
yabahiro 39:784552c26163 1123 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1124 motor[TIRE_FL].dir = BACK;
yabahiro 39:784552c26163 1125 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1126 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1127 break;
yabahiro 39:784552c26163 1128 case 1:
yabahiro 39:784552c26163 1129 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1130 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1131 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1132 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1133 break;
yabahiro 39:784552c26163 1134 case 3:
yabahiro 39:784552c26163 1135 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 1136 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1137 motor[TIRE_BL].pwm = 20;
yabahiro 39:784552c26163 1138 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1139 break;
yabahiro 39:784552c26163 1140 case 2:
yabahiro 39:784552c26163 1141 motor[TIRE_FL].pwm = 30;
yabahiro 39:784552c26163 1142 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1143 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1144 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1145 break;
yabahiro 33:dd598bb23ad1 1146 }
yabahiro 39:784552c26163 1147 if(g[3]==0&&g[2]==0) {
yabahiro 46:68296caae1af 1148 mode=25;
yabahiro 39:784552c26163 1149 }
yabahiro 46:68296caae1af 1150 } else if(mode==25) {
yabahiro 46:68296caae1af 1151 motor[TIRE_FR].pwm = 100;
yabahiro 46:68296caae1af 1152 motor[TIRE_FR].dir = BRAKE;
yabahiro 46:68296caae1af 1153 motor[TIRE_FL].pwm = 100;
yabahiro 46:68296caae1af 1154 motor[TIRE_FL].dir = BRAKE;
yabahiro 46:68296caae1af 1155 motor[TIRE_BR].pwm = 100;
yabahiro 46:68296caae1af 1156 motor[TIRE_BR].dir = BRAKE;
yabahiro 46:68296caae1af 1157 motor[TIRE_BL].pwm = 100;
yabahiro 46:68296caae1af 1158 motor[TIRE_BL].dir = BRAKE;
yabahiro 46:68296caae1af 1159 if(DOLS==true||UPLS==true) {
yabahiro 48:5562a99479e5 1160 if(DOLS==true||UPLS==true) {
yabahiro 48:5562a99479e5 1161 motor[MOTOR_0].pwm = 200;
yabahiro 48:5562a99479e5 1162 motor[MOTOR_0].dir = BRAKE;
yabahiro 48:5562a99479e5 1163 countss=0;
yabahiro 48:5562a99479e5 1164 mode=26;
yabahiro 48:5562a99479e5 1165 }
yabahiro 46:68296caae1af 1166 } else {
yabahiro 46:68296caae1af 1167 motor[MOTOR_0].pwm = 100;
yabahiro 46:68296caae1af 1168 motor[MOTOR_0].dir = BACK;
yabahiro 46:68296caae1af 1169 }
yabahiro 46:68296caae1af 1170 } else if(mode==26) {
yabahiro 39:784552c26163 1171 switch(g[4]) {
yabahiro 39:784552c26163 1172 case 98:
kishibekairohan 45:0cf48a0605cd 1173 motor[TIRE_FR].pwm = 60;
yabahiro 39:784552c26163 1174 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1175 motor[TIRE_FL].pwm = 60;
yabahiro 39:784552c26163 1176 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1177 motor[TIRE_BR].pwm = 60;
yabahiro 39:784552c26163 1178 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1179 motor[TIRE_BL].pwm = 60;
yabahiro 39:784552c26163 1180 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1181 break;
yabahiro 39:784552c26163 1182 case 99:
yabahiro 39:784552c26163 1183 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1184 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1185 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1186 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1187 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1188 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1189 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1190 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1191 break;
yabahiro 39:784552c26163 1192 case 0:
kishibekairohan 45:0cf48a0605cd 1193 motor[TIRE_FR].pwm = 60;
yabahiro 39:784552c26163 1194 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1195 motor[TIRE_FL].pwm = 60;
yabahiro 39:784552c26163 1196 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1197 motor[TIRE_BR].pwm = 60;
yabahiro 39:784552c26163 1198 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1199 motor[TIRE_BL].pwm = 60;
yabahiro 39:784552c26163 1200 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1201 break;
yabahiro 39:784552c26163 1202 case 255:
yabahiro 39:784552c26163 1203 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1204 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1205 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1206 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1207 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1208 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1209 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1210 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1211 break;
yabahiro 39:784552c26163 1212 case 253:
kishibekairohan 45:0cf48a0605cd 1213 motor[TIRE_FR].pwm = 60;
yabahiro 39:784552c26163 1214 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1215 motor[TIRE_FL].pwm = 20;
yabahiro 39:784552c26163 1216 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1217 motor[TIRE_BR].pwm = 20;
yabahiro 39:784552c26163 1218 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1219 motor[TIRE_BL].pwm = 60;
yabahiro 39:784552c26163 1220 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1221 break;
yabahiro 39:784552c26163 1222 case 254:
kishibekairohan 45:0cf48a0605cd 1223 motor[TIRE_FR].pwm = 60;
yabahiro 39:784552c26163 1224 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1225 motor[TIRE_FL].pwm = 40;
yabahiro 39:784552c26163 1226 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1227 motor[TIRE_BR].pwm = 40;
yabahiro 39:784552c26163 1228 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1229 motor[TIRE_BL].pwm = 60;
yabahiro 39:784552c26163 1230 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1231 break;
yabahiro 39:784552c26163 1232 case 1:
yabahiro 39:784552c26163 1233 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1234 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1235 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1236 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1237 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1238 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1239 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1240 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1241 break;
yabahiro 39:784552c26163 1242 case 3:
kishibekairohan 45:0cf48a0605cd 1243 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 1244 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1245 motor[TIRE_FL].pwm = 60;
yabahiro 39:784552c26163 1246 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1247 motor[TIRE_BR].pwm = 60;
yabahiro 39:784552c26163 1248 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1249 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 1250 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1251 break;
yabahiro 39:784552c26163 1252 case 2:
kishibekairohan 45:0cf48a0605cd 1253 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 1254 motor[TIRE_FR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1255 motor[TIRE_FL].pwm = 60;
yabahiro 39:784552c26163 1256 motor[TIRE_FL].dir = FOR;
kishibekairohan 45:0cf48a0605cd 1257 motor[TIRE_BR].pwm = 60;
yabahiro 39:784552c26163 1258 motor[TIRE_BR].dir = BACK;
kishibekairohan 45:0cf48a0605cd 1259 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 1260 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1261 break;
yabahiro 39:784552c26163 1262 }
kishibekairohan 45:0cf48a0605cd 1263 if(g[0]==98) {
yabahiro 39:784552c26163 1264 mode=31;
yabahiro 33:dd598bb23ad1 1265 }
yabahiro 33:dd598bb23ad1 1266 }
yabahiro 46:68296caae1af 1267 } else {
yabahiro 39:784552c26163 1268 if(mode==21) {
kishibekairohan 47:a9cad8502999 1269 motor[TIRE_FR].pwm = 255;
kishibekairohan 47:a9cad8502999 1270 motor[TIRE_FR].dir = BRAKE;
yabahiro 39:784552c26163 1271 motor[TIRE_FL].pwm = 30;
yabahiro 33:dd598bb23ad1 1272 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1273 motor[TIRE_BR].pwm = 30;
yabahiro 33:dd598bb23ad1 1274 motor[TIRE_BR].dir = BACK;
kishibekairohan 47:a9cad8502999 1275 motor[TIRE_BL].pwm = 255;
kishibekairohan 47:a9cad8502999 1276 motor[TIRE_BL].dir = BRAKE;
yabahiro 39:784552c26163 1277 if(g[1]==0) {
yabahiro 39:784552c26163 1278 mode=22;
yabahiro 39:784552c26163 1279 fast=60;
yabahiro 39:784552c26163 1280 normal=40;
kishibekairohan 47:a9cad8502999 1281 slow=25;
yabahiro 39:784552c26163 1282 }
yabahiro 39:784552c26163 1283 } else if(mode==22) {
yabahiro 48:5562a99479e5 1284 if(g[0]==98) {
kishibekairohan 47:a9cad8502999 1285 slow=25;
kishibekairohan 47:a9cad8502999 1286 normal=30;
kishibekairohan 47:a9cad8502999 1287 fast=40;
kishibekairohan 47:a9cad8502999 1288 }
yabahiro 39:784552c26163 1289 if(g[3]==0) {
kishibekairohan 47:a9cad8502999 1290 slow=25;
kishibekairohan 47:a9cad8502999 1291 normal=40;
kishibekairohan 47:a9cad8502999 1292 fast=40;
yabahiro 39:784552c26163 1293 mode=23;
yabahiro 39:784552c26163 1294 }
yabahiro 39:784552c26163 1295 switch(g[0]) {
yabahiro 39:784552c26163 1296 case 98:
yabahiro 48:5562a99479e5 1297 solenoid.solenoid2 = SOLENOID_OFF;
kishibekairohan 47:a9cad8502999 1298 fast=40;
kishibekairohan 47:a9cad8502999 1299 normal=30;
kishibekairohan 47:a9cad8502999 1300 slow=25;
yabahiro 39:784552c26163 1301 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1302 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1303 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1304 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1305 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1306 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1307 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1308 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1309 break;
yabahiro 39:784552c26163 1310 case 0:
yabahiro 39:784552c26163 1311 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1312 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1313 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1314 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1315 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1316 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1317 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1318 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1319 mtc=true;
yabahiro 39:784552c26163 1320 break;
yabahiro 39:784552c26163 1321 case 255:
yabahiro 39:784552c26163 1322 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1323 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1324 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1325 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1326 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1327 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1328 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1329 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1330 mtc=true;
yabahiro 39:784552c26163 1331 break;
yabahiro 39:784552c26163 1332 case 253:
yabahiro 39:784552c26163 1333 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1334 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1335 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1336 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1337 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1338 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1339 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1340 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1341 mtc=true;
yabahiro 39:784552c26163 1342 break;
yabahiro 39:784552c26163 1343 case 254:
yabahiro 39:784552c26163 1344 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1345 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1346 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1347 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1348 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1349 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1350 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1351 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1352 mtc=true;
yabahiro 39:784552c26163 1353 break;
yabahiro 39:784552c26163 1354 case 1:
yabahiro 39:784552c26163 1355 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1356 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1357 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1358 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1359 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1360 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1361 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1362 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1363 mtc=true;
yabahiro 39:784552c26163 1364 break;
yabahiro 39:784552c26163 1365 case 3:
yabahiro 39:784552c26163 1366 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1367 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1368 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1369 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1370 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1371 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1372 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1373 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1374 mtc=true;
yabahiro 39:784552c26163 1375 break;
yabahiro 39:784552c26163 1376 case 2:
yabahiro 39:784552c26163 1377 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1378 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1379 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1380 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1381 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1382 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1383 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1384 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1385 mtc=true;
yabahiro 39:784552c26163 1386 break;
yabahiro 39:784552c26163 1387 }
yabahiro 39:784552c26163 1388 if(g[0]!=98&&mtc==true) {
yabahiro 39:784552c26163 1389 switch(g[0]) {
yabahiro 39:784552c26163 1390 case 0:
yabahiro 39:784552c26163 1391 mtc=false;
yabahiro 39:784552c26163 1392 break;
yabahiro 39:784552c26163 1393 case 255:
yabahiro 39:784552c26163 1394 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1395 mtc=false;
yabahiro 39:784552c26163 1396 break;
yabahiro 39:784552c26163 1397 case 253:
yabahiro 39:784552c26163 1398 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1399 mtc=false;
yabahiro 39:784552c26163 1400 break;
yabahiro 39:784552c26163 1401 case 254:
yabahiro 39:784552c26163 1402 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1403 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1404 mtc=false;
yabahiro 39:784552c26163 1405 break;
yabahiro 39:784552c26163 1406 case 1:
yabahiro 39:784552c26163 1407 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1408 mtc=false;
yabahiro 39:784552c26163 1409 break;
yabahiro 39:784552c26163 1410 case 3:
yabahiro 39:784552c26163 1411 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1412 mtc=false;
yabahiro 39:784552c26163 1413 break;
yabahiro 39:784552c26163 1414 case 2:
yabahiro 39:784552c26163 1415 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1416 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1417 mtc=false;
yabahiro 39:784552c26163 1418 break;
yabahiro 39:784552c26163 1419 }
yabahiro 39:784552c26163 1420 }
yabahiro 39:784552c26163 1421 } else if(mode==23) {
yabahiro 39:784552c26163 1422 if(UPLS==true||DOLS==true) {
yabahiro 48:5562a99479e5 1423 if(UPLS==true||DOLS==true) {
yabahiro 48:5562a99479e5 1424 motor[MOTOR_0].pwm = 200;
yabahiro 48:5562a99479e5 1425 motor[MOTOR_0].dir = BRAKE;
yabahiro 48:5562a99479e5 1426 fast=60;
yabahiro 48:5562a99479e5 1427 normal=40;
yabahiro 48:5562a99479e5 1428 slow=20;
yabahiro 48:5562a99479e5 1429 countss=0;
yabahiro 48:5562a99479e5 1430 mode=24;
yabahiro 48:5562a99479e5 1431 }
yabahiro 39:784552c26163 1432 } else {
yabahiro 39:784552c26163 1433 motor[MOTOR_0].pwm = 100;
yabahiro 39:784552c26163 1434 motor[MOTOR_0].dir = BACK;
yabahiro 39:784552c26163 1435 }
kishibekairohan 47:a9cad8502999 1436 motor[TIRE_FR].pwm = 100;
kishibekairohan 47:a9cad8502999 1437 motor[TIRE_FR].dir = BRAKE;
kishibekairohan 47:a9cad8502999 1438 motor[TIRE_FL].pwm = 100;
kishibekairohan 47:a9cad8502999 1439 motor[TIRE_FL].dir = BRAKE;
kishibekairohan 47:a9cad8502999 1440 motor[TIRE_BR].pwm = 100;
kishibekairohan 47:a9cad8502999 1441 motor[TIRE_BR].dir = BRAKE;
kishibekairohan 47:a9cad8502999 1442 motor[TIRE_BL].pwm = 100;
kishibekairohan 47:a9cad8502999 1443 motor[TIRE_BL].dir = BRAKE;
yabahiro 39:784552c26163 1444 } else if(mode==24) {
yabahiro 39:784552c26163 1445 if(g[0]==98&&countss>=40000) {
yabahiro 39:784552c26163 1446 mode=31;
yabahiro 39:784552c26163 1447 countss=0;
yabahiro 39:784552c26163 1448 }
yabahiro 39:784552c26163 1449 switch(g[0]) {
yabahiro 39:784552c26163 1450 case 98:
kishibekairohan 47:a9cad8502999 1451 fast=40;
kishibekairohan 47:a9cad8502999 1452 normal=30;
kishibekairohan 47:a9cad8502999 1453 slow=25;
yabahiro 39:784552c26163 1454 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1455 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1456 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1457 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1458 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1459 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1460 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1461 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1462 break;
yabahiro 39:784552c26163 1463 case 0:
yabahiro 39:784552c26163 1464 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1465 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1466 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1467 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1468 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1469 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1470 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1471 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1472 mtc=true;
yabahiro 39:784552c26163 1473 break;
yabahiro 39:784552c26163 1474 case 255:
yabahiro 39:784552c26163 1475 motor[TIRE_FR].pwm = fast;
yabahiro 39:784552c26163 1476 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1477 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1478 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1479 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1480 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1481 motor[TIRE_BL].pwm = fast;
yabahiro 39:784552c26163 1482 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1483 mtc=true;
yabahiro 39:784552c26163 1484 break;
yabahiro 39:784552c26163 1485 case 253:
yabahiro 39:784552c26163 1486 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1487 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1488 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1489 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1490 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1491 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1492 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1493 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1494 mtc=true;
yabahiro 39:784552c26163 1495 break;
yabahiro 39:784552c26163 1496 case 254:
yabahiro 39:784552c26163 1497 motor[TIRE_FR].pwm = normal;
yabahiro 39:784552c26163 1498 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1499 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1500 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1501 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1502 motor[TIRE_BR].dir = FREE;
yabahiro 39:784552c26163 1503 motor[TIRE_BL].pwm = normal;
yabahiro 39:784552c26163 1504 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1505 mtc=true;
yabahiro 39:784552c26163 1506 break;
yabahiro 39:784552c26163 1507 case 1:
yabahiro 39:784552c26163 1508 motor[TIRE_FR].pwm = slow;
yabahiro 39:784552c26163 1509 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1510 motor[TIRE_FL].pwm = fast;
yabahiro 39:784552c26163 1511 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1512 motor[TIRE_BR].pwm = fast;
yabahiro 39:784552c26163 1513 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1514 motor[TIRE_BL].pwm = slow;
yabahiro 39:784552c26163 1515 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1516 mtc=true;
yabahiro 39:784552c26163 1517 break;
yabahiro 39:784552c26163 1518 case 3:
yabahiro 39:784552c26163 1519 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1520 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1521 motor[TIRE_FL].pwm = slow;
yabahiro 39:784552c26163 1522 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1523 motor[TIRE_BR].pwm = slow;
yabahiro 39:784552c26163 1524 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1525 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1526 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1527 mtc=true;
yabahiro 39:784552c26163 1528 break;
yabahiro 39:784552c26163 1529 case 2:
yabahiro 39:784552c26163 1530 motor[TIRE_FR].pwm = 0;
yabahiro 39:784552c26163 1531 motor[TIRE_FR].dir = FREE;
yabahiro 39:784552c26163 1532 motor[TIRE_FL].pwm = normal;
yabahiro 39:784552c26163 1533 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1534 motor[TIRE_BR].pwm = normal;
yabahiro 39:784552c26163 1535 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1536 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1537 motor[TIRE_BL].dir = FREE;
yabahiro 39:784552c26163 1538 mtc=true;
yabahiro 39:784552c26163 1539 break;
yabahiro 39:784552c26163 1540 }
yabahiro 39:784552c26163 1541 if(g[1]!=98&&mtc==true) {
yabahiro 39:784552c26163 1542 switch(g[1]) {
yabahiro 39:784552c26163 1543 case 0:
yabahiro 39:784552c26163 1544 mtc=false;
yabahiro 39:784552c26163 1545 break;
yabahiro 39:784552c26163 1546 case 255:
yabahiro 39:784552c26163 1547 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1548 mtc=false;
yabahiro 39:784552c26163 1549 break;
yabahiro 39:784552c26163 1550 case 253:
yabahiro 39:784552c26163 1551 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1552 mtc=false;
yabahiro 39:784552c26163 1553 break;
yabahiro 39:784552c26163 1554 case 254:
yabahiro 39:784552c26163 1555 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1556 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1557 mtc=false;
yabahiro 39:784552c26163 1558 break;
yabahiro 39:784552c26163 1559 case 1:
yabahiro 39:784552c26163 1560 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1561 mtc=false;
yabahiro 39:784552c26163 1562 break;
yabahiro 39:784552c26163 1563 case 3:
yabahiro 39:784552c26163 1564 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1565 mtc=false;
yabahiro 39:784552c26163 1566 break;
yabahiro 39:784552c26163 1567 case 2:
yabahiro 39:784552c26163 1568 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1569 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1570 mtc=false;
yabahiro 39:784552c26163 1571 break;
yabahiro 39:784552c26163 1572 }
yabahiro 33:dd598bb23ad1 1573 }
yabahiro 33:dd598bb23ad1 1574 }
yabahiro 33:dd598bb23ad1 1575 }
yabahiro 48:5562a99479e5 1576
kishibekairohan 47:a9cad8502999 1577 /*
yabahiro 39:784552c26163 1578 if(mode==31) {
yabahiro 33:dd598bb23ad1 1579 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1580 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1581 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1582 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1583 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1584 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1585 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1586 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1587 if(countss>=5000) {
yabahiro 33:dd598bb23ad1 1588 countss=0;
yabahiro 33:dd598bb23ad1 1589 mode=33;
yabahiro 33:dd598bb23ad1 1590 }
yabahiro 33:dd598bb23ad1 1591 } else if(mode==33) {
yabahiro 33:dd598bb23ad1 1592 motor[TIRE_FR].pwm = 30;
yabahiro 39:784552c26163 1593 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1594 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1595 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1596 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1597 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1598 motor[TIRE_BL].pwm = 30;
yabahiro 39:784552c26163 1599 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1600 if(g[3]==0) {
yabahiro 39:784552c26163 1601 cross=0;
yabahiro 33:dd598bb23ad1 1602 countss=0;
yabahiro 33:dd598bb23ad1 1603 mode=40;
yabahiro 33:dd598bb23ad1 1604 }
yabahiro 48:5562a99479e5 1605 } else
kishibekairohan 47:a9cad8502999 1606 */
kishibekairohan 47:a9cad8502999 1607 if(mode==31) {
kishibekairohan 47:a9cad8502999 1608 motor[TIRE_FR].pwm = 45;
kishibekairohan 47:a9cad8502999 1609 motor[TIRE_FR].dir = BACK;
kishibekairohan 47:a9cad8502999 1610 motor[TIRE_FL].pwm = 255;
kishibekairohan 47:a9cad8502999 1611 motor[TIRE_FL].dir = BRAKE;
kishibekairohan 47:a9cad8502999 1612 motor[TIRE_BR].pwm = 255;
kishibekairohan 47:a9cad8502999 1613 motor[TIRE_BR].dir = BRAKE;
kishibekairohan 47:a9cad8502999 1614 motor[TIRE_BL].pwm = 45;
kishibekairohan 47:a9cad8502999 1615 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 1616 if(g[2]==0) {
kishibekairohan 47:a9cad8502999 1617 cross=0;
kishibekairohan 47:a9cad8502999 1618 countss=0;
kishibekairohan 47:a9cad8502999 1619 mode=40;
kishibekairohan 47:a9cad8502999 1620 }
yabahiro 33:dd598bb23ad1 1621 } else if(mode==40) {
yabahiro 33:dd598bb23ad1 1622 switch(g[3]) {
yabahiro 33:dd598bb23ad1 1623 case 98:
kishibekairohan 47:a9cad8502999 1624 motor[TIRE_FR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1625 motor[TIRE_FR].dir = BACK;
kishibekairohan 47:a9cad8502999 1626 motor[TIRE_FL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1627 motor[TIRE_FL].dir = BACK;
kishibekairohan 47:a9cad8502999 1628 motor[TIRE_BR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1629 motor[TIRE_BR].dir = FOR;
kishibekairohan 47:a9cad8502999 1630 motor[TIRE_BL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1631 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1632 if(countss>10000) {
yabahiro 33:dd598bb23ad1 1633 cross++;
yabahiro 33:dd598bb23ad1 1634 countss=0;
yabahiro 33:dd598bb23ad1 1635 }
yabahiro 33:dd598bb23ad1 1636 mtc2=true;
yabahiro 39:784552c26163 1637 if(cross==1) {
yabahiro 33:dd598bb23ad1 1638 mode=41;
yabahiro 33:dd598bb23ad1 1639 countss=0;
yabahiro 33:dd598bb23ad1 1640 cross=0;
yabahiro 33:dd598bb23ad1 1641 }
yabahiro 33:dd598bb23ad1 1642 break;
yabahiro 33:dd598bb23ad1 1643 case 0:
kishibekairohan 47:a9cad8502999 1644 motor[TIRE_FR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1645 motor[TIRE_FR].dir = BACK;
kishibekairohan 47:a9cad8502999 1646 motor[TIRE_FL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1647 motor[TIRE_FL].dir = BACK;
kishibekairohan 47:a9cad8502999 1648 motor[TIRE_BR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1649 motor[TIRE_BR].dir = FOR;
kishibekairohan 47:a9cad8502999 1650 motor[TIRE_BL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1651 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1652 mtc2=true;
yabahiro 33:dd598bb23ad1 1653 break;
yabahiro 33:dd598bb23ad1 1654 case 255:
kishibekairohan 47:a9cad8502999 1655 motor[TIRE_FR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1656 motor[TIRE_FR].dir = BACK;
kishibekairohan 47:a9cad8502999 1657 motor[TIRE_FL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1658 motor[TIRE_FL].dir = BACK;
kishibekairohan 47:a9cad8502999 1659 motor[TIRE_BR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1660 motor[TIRE_BR].dir = FOR;
kishibekairohan 47:a9cad8502999 1661 motor[TIRE_BL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1662 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1663 mtc2=true;
yabahiro 33:dd598bb23ad1 1664 break;
yabahiro 33:dd598bb23ad1 1665 case 253:
yabahiro 33:dd598bb23ad1 1666 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1667 motor[TIRE_FR].dir = FREE;
kishibekairohan 47:a9cad8502999 1668 motor[TIRE_FL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1669 motor[TIRE_FL].dir = BACK;
kishibekairohan 47:a9cad8502999 1670 motor[TIRE_BR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1671 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1672 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1673 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1674 mtc2=true;
yabahiro 33:dd598bb23ad1 1675 break;
yabahiro 33:dd598bb23ad1 1676 case 254:
yabahiro 33:dd598bb23ad1 1677 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1678 motor[TIRE_FR].dir = FREE;
kishibekairohan 47:a9cad8502999 1679 motor[TIRE_FL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1680 motor[TIRE_FL].dir = BACK;
kishibekairohan 47:a9cad8502999 1681 motor[TIRE_BR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1682 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 1683 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1684 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1685 mtc2=true;
yabahiro 33:dd598bb23ad1 1686 break;
yabahiro 33:dd598bb23ad1 1687 case 1:
kishibekairohan 47:a9cad8502999 1688 motor[TIRE_FR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1689 motor[TIRE_FR].dir = BACK;
kishibekairohan 47:a9cad8502999 1690 motor[TIRE_FL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1691 motor[TIRE_FL].dir = BACK;
kishibekairohan 47:a9cad8502999 1692 motor[TIRE_BR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1693 motor[TIRE_BR].dir = FOR;
kishibekairohan 47:a9cad8502999 1694 motor[TIRE_BL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 1695 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1696 mtc2=true;
yabahiro 33:dd598bb23ad1 1697 break;
yabahiro 33:dd598bb23ad1 1698 case 3:
kishibekairohan 47:a9cad8502999 1699 motor[TIRE_FR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1700 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1701 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1702 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1703 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1704 motor[TIRE_BR].dir = FREE;
kishibekairohan 47:a9cad8502999 1705 motor[TIRE_BL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 1706 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1707 mtc2=true;
yabahiro 33:dd598bb23ad1 1708 break;
yabahiro 33:dd598bb23ad1 1709 case 2:
kishibekairohan 47:a9cad8502999 1710 motor[TIRE_FR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1711 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1712 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1713 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1714 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1715 motor[TIRE_BR].dir = FREE;
kishibekairohan 47:a9cad8502999 1716 motor[TIRE_BL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 1717 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1718 mtc2=true;
yabahiro 33:dd598bb23ad1 1719 break;
yabahiro 33:dd598bb23ad1 1720 }
yabahiro 33:dd598bb23ad1 1721 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 1722 switch(g[2]) {
yabahiro 33:dd598bb23ad1 1723 case 0:
yabahiro 33:dd598bb23ad1 1724 mtc2=false;
yabahiro 33:dd598bb23ad1 1725 break;
yabahiro 33:dd598bb23ad1 1726 case 255:
yabahiro 39:784552c26163 1727 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 1728 mtc2=false;
yabahiro 33:dd598bb23ad1 1729 break;
yabahiro 33:dd598bb23ad1 1730 case 253:
yabahiro 39:784552c26163 1731 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 1732 mtc2=false;
yabahiro 33:dd598bb23ad1 1733 break;
yabahiro 33:dd598bb23ad1 1734 case 254:
yabahiro 39:784552c26163 1735 motor[TIRE_FL].pwm += 20;
yabahiro 39:784552c26163 1736 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1737 mtc2=false;
yabahiro 33:dd598bb23ad1 1738 break;
yabahiro 33:dd598bb23ad1 1739 case 1:
yabahiro 39:784552c26163 1740 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 1741 mtc2=false;
yabahiro 33:dd598bb23ad1 1742 break;
yabahiro 33:dd598bb23ad1 1743 case 3:
yabahiro 39:784552c26163 1744 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 1745 mtc2=false;
yabahiro 33:dd598bb23ad1 1746 break;
yabahiro 33:dd598bb23ad1 1747 case 2:
yabahiro 39:784552c26163 1748 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1749 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1750 mtc2=false;
yabahiro 33:dd598bb23ad1 1751 break;
yabahiro 33:dd598bb23ad1 1752 }
yabahiro 33:dd598bb23ad1 1753 }
yabahiro 33:dd598bb23ad1 1754 } else if(mode==41) {
yabahiro 33:dd598bb23ad1 1755 if(LIF||LIB) {
yabahiro 33:dd598bb23ad1 1756 mode=42;
yabahiro 33:dd598bb23ad1 1757 }
yabahiro 33:dd598bb23ad1 1758 motor[TIRE_FR].pwm = 30;
yabahiro 33:dd598bb23ad1 1759 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1760 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1761 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1762 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1763 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1764 motor[TIRE_BL].pwm = 30;
yabahiro 33:dd598bb23ad1 1765 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1766 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 1767 countss=0;
yabahiro 33:dd598bb23ad1 1768 mode=70;
yabahiro 33:dd598bb23ad1 1769 normal=60;
yabahiro 33:dd598bb23ad1 1770 fast=70;
yabahiro 33:dd598bb23ad1 1771 slow=40;
yabahiro 33:dd598bb23ad1 1772 }
yabahiro 33:dd598bb23ad1 1773 } else if(mode==42) {
kishibekairohan 47:a9cad8502999 1774 motor[TIRE_FR].pwm = 40;
yabahiro 39:784552c26163 1775 motor[TIRE_FR].dir = FOR;
yabahiro 39:784552c26163 1776 motor[TIRE_FL].pwm = 0;
yabahiro 39:784552c26163 1777 motor[TIRE_FL].dir = FREE;
yabahiro 39:784552c26163 1778 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1779 motor[TIRE_BR].dir = FREE;
kishibekairohan 47:a9cad8502999 1780 motor[TIRE_BL].pwm = 40;
yabahiro 39:784552c26163 1781 motor[TIRE_BL].dir = BACK;
yabahiro 39:784552c26163 1782 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 1783 countss=0;
yabahiro 39:784552c26163 1784 mode=70;
yabahiro 33:dd598bb23ad1 1785 }
yabahiro 39:784552c26163 1786 } else if(mode==70) {
yabahiro 33:dd598bb23ad1 1787 switch(g[0]) {
yabahiro 33:dd598bb23ad1 1788 case 99:
yabahiro 33:dd598bb23ad1 1789 if(countss>=100000) {
yabahiro 33:dd598bb23ad1 1790 mode=100;
yabahiro 33:dd598bb23ad1 1791 }
yabahiro 33:dd598bb23ad1 1792 break;
yabahiro 33:dd598bb23ad1 1793 case 98:
yabahiro 33:dd598bb23ad1 1794 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1795 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1796 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1797 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1798 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1799 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1800 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1801 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1802 break;
yabahiro 33:dd598bb23ad1 1803 case 0:
yabahiro 39:784552c26163 1804 motor[TIRE_FR].pwm = 80;
yabahiro 33:dd598bb23ad1 1805 motor[TIRE_FR].dir = BACK;
yabahiro 39:784552c26163 1806 motor[TIRE_FL].pwm = 80;
yabahiro 33:dd598bb23ad1 1807 motor[TIRE_FL].dir = FOR;
yabahiro 39:784552c26163 1808 motor[TIRE_BR].pwm = 80;
yabahiro 33:dd598bb23ad1 1809 motor[TIRE_BR].dir = BACK;
yabahiro 39:784552c26163 1810 motor[TIRE_BL].pwm = 80;
yabahiro 33:dd598bb23ad1 1811 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1812 mtc=true;
yabahiro 33:dd598bb23ad1 1813 break;
yabahiro 33:dd598bb23ad1 1814 case 255:
yabahiro 33:dd598bb23ad1 1815 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 1816 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1817 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1818 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1819 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1820 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1821 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 1822 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1823 mtc=true;
yabahiro 33:dd598bb23ad1 1824 break;
yabahiro 33:dd598bb23ad1 1825 case 253:
yabahiro 33:dd598bb23ad1 1826 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1827 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1828 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1829 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1830 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1831 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1832 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1833 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1834 mtc=true;
yabahiro 33:dd598bb23ad1 1835 break;
yabahiro 33:dd598bb23ad1 1836 case 254:
yabahiro 33:dd598bb23ad1 1837 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 1838 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1839 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 1840 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 1841 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 1842 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 1843 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 1844 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1845 mtc=true;
yabahiro 33:dd598bb23ad1 1846 break;
yabahiro 33:dd598bb23ad1 1847 case 1:
yabahiro 33:dd598bb23ad1 1848 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 1849 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 1850 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 1851 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1852 motor[TIRE_BR].pwm = fast;
yabahiro 33:dd598bb23ad1 1853 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1854 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 1855 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1856 mtc=true;
yabahiro 33:dd598bb23ad1 1857 break;
yabahiro 33:dd598bb23ad1 1858 case 3:
yabahiro 33:dd598bb23ad1 1859 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1860 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1861 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 1862 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1863 motor[TIRE_BR].pwm = slow;
yabahiro 33:dd598bb23ad1 1864 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1865 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1866 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1867 mtc=true;
yabahiro 33:dd598bb23ad1 1868 break;
yabahiro 33:dd598bb23ad1 1869 case 2:
yabahiro 33:dd598bb23ad1 1870 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 1871 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 1872 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 1873 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 1874 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 1875 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 1876 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 1877 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 1878 mtc=true;
yabahiro 33:dd598bb23ad1 1879 break;
yabahiro 33:dd598bb23ad1 1880 }
yabahiro 39:784552c26163 1881 if(g[1]!=98&&mtc==true) {
yabahiro 39:784552c26163 1882 switch(g[1]) {
yabahiro 39:784552c26163 1883 case 0:
yabahiro 39:784552c26163 1884 mtc=false;
yabahiro 39:784552c26163 1885 break;
yabahiro 39:784552c26163 1886 case 255:
yabahiro 39:784552c26163 1887 motor[TIRE_BR].pwm += 5;
yabahiro 39:784552c26163 1888 mtc=false;
yabahiro 39:784552c26163 1889 break;
yabahiro 39:784552c26163 1890 case 253:
yabahiro 39:784552c26163 1891 motor[TIRE_BR].pwm += 10;
yabahiro 39:784552c26163 1892 mtc=false;
yabahiro 39:784552c26163 1893 break;
yabahiro 39:784552c26163 1894 case 254:
yabahiro 39:784552c26163 1895 motor[TIRE_BR].pwm += 20;
yabahiro 39:784552c26163 1896 motor[TIRE_BL].pwm = 0;
yabahiro 39:784552c26163 1897 mtc=false;
yabahiro 39:784552c26163 1898 break;
yabahiro 39:784552c26163 1899 case 1:
yabahiro 39:784552c26163 1900 motor[TIRE_BL].pwm += 5;
yabahiro 39:784552c26163 1901 mtc=false;
yabahiro 39:784552c26163 1902 break;
yabahiro 39:784552c26163 1903 case 3:
yabahiro 39:784552c26163 1904 motor[TIRE_BL].pwm += 10;
yabahiro 39:784552c26163 1905 mtc=false;
yabahiro 39:784552c26163 1906 break;
yabahiro 39:784552c26163 1907 case 2:
yabahiro 39:784552c26163 1908 motor[TIRE_BL].pwm += 20;
yabahiro 39:784552c26163 1909 motor[TIRE_BR].pwm = 0;
yabahiro 39:784552c26163 1910 mtc=false;
yabahiro 39:784552c26163 1911 break;
yabahiro 39:784552c26163 1912 }
yabahiro 33:dd598bb23ad1 1913 }
yabahiro 33:dd598bb23ad1 1914 } else if(mode==100) {
kishibekairohan 47:a9cad8502999 1915 motor[TIRE_FR].pwm = 50;
yabahiro 33:dd598bb23ad1 1916 motor[TIRE_FR].dir = BACK;
kishibekairohan 47:a9cad8502999 1917 motor[TIRE_FL].pwm = 50;
yabahiro 33:dd598bb23ad1 1918 motor[TIRE_FL].dir = FOR;
kishibekairohan 47:a9cad8502999 1919 motor[TIRE_BR].pwm = 50;
yabahiro 33:dd598bb23ad1 1920 motor[TIRE_BR].dir = BACK;
kishibekairohan 47:a9cad8502999 1921 motor[TIRE_BL].pwm = 50;
yabahiro 33:dd598bb23ad1 1922 motor[TIRE_BL].dir = FOR;
yabahiro 39:784552c26163 1923 } else {
yabahiro 33:dd598bb23ad1 1924 }
yabahiro 39:784552c26163 1925
kishibekairohan 13:b6e02d6261d7 1926 }
kishibekairohan 13:b6e02d6261d7 1927 #endif
kishibekairohan 13:b6e02d6261d7 1928
kishibekairohan 13:b6e02d6261d7 1929 #if USE_PROCESS_NUM>3
Ryosei 27:dd9f27fce7d1 1930 static void Process3()
kishibekairohan 13:b6e02d6261d7 1931 {
yabahiro 33:dd598bb23ad1 1932 //Clearly 赤ゾーン
kishibekairohan 35:33c6cdba5630 1933 LED::LED::TapeledMode(3);
yabahiro 33:dd598bb23ad1 1934 countss++;
yabahiro 33:dd598bb23ad1 1935 if(mode==1) {//スタートゾーンから白線検知
yabahiro 33:dd598bb23ad1 1936 fast=40;
yabahiro 33:dd598bb23ad1 1937 normal=30;
yabahiro 33:dd598bb23ad1 1938 slow=20;
kishibekairohan 42:980af34f6fe3 1939 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1940 motor[TIRE_FR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1941 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1942 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1943 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1944 motor[TIRE_BR].dir = BACK;
kishibekairohan 42:980af34f6fe3 1945 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 1946 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1947 if(g[2]==0&&countss>=100000) {
yabahiro 33:dd598bb23ad1 1948 countss=100000;
yabahiro 33:dd598bb23ad1 1949 cross=0;
yabahiro 33:dd598bb23ad1 1950 mode=3;
yabahiro 33:dd598bb23ad1 1951 }
yabahiro 46:68296caae1af 1952 } else if(mode==3) { //横ライントレースから縦ライントレースへ
kishibekairohan 44:2aff0da5ebdb 1953 motor[TIRE_FR].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 1954 motor[TIRE_FR].dir = BRAKE;
kishibekairohan 42:980af34f6fe3 1955 motor[TIRE_FL].pwm = 30;
yabahiro 33:dd598bb23ad1 1956 motor[TIRE_FL].dir = FOR;
kishibekairohan 42:980af34f6fe3 1957 motor[TIRE_BR].pwm = 30;
yabahiro 33:dd598bb23ad1 1958 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 1959 motor[TIRE_BL].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 1960 motor[TIRE_BL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 1961 if(g[0]==0) {
yabahiro 33:dd598bb23ad1 1962 mode=10;
yabahiro 33:dd598bb23ad1 1963 countss=100000;
yabahiro 33:dd598bb23ad1 1964 }
yabahiro 46:68296caae1af 1965 } else if(mode==10) { //縦ライントレース
yabahiro 33:dd598bb23ad1 1966 switch(g[0]) {
yabahiro 33:dd598bb23ad1 1967 case 98:
kishibekairohan 44:2aff0da5ebdb 1968 motor[TIRE_FR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 1969 motor[TIRE_FR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 1970 motor[TIRE_FL].pwm = normal+50;
yabahiro 33:dd598bb23ad1 1971 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 1972 motor[TIRE_BR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 1973 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 1974 motor[TIRE_BL].pwm = normal+50;
yabahiro 33:dd598bb23ad1 1975 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 1976 mtc=true;
yabahiro 33:dd598bb23ad1 1977 if(countss>80000) {
yabahiro 33:dd598bb23ad1 1978 cross++;
yabahiro 33:dd598bb23ad1 1979 countss=0;
yabahiro 33:dd598bb23ad1 1980 }
yabahiro 46:68296caae1af 1981 if(cross==2) {
yabahiro 46:68296caae1af 1982 fast = 10;
yabahiro 46:68296caae1af 1983 normal = 10;
kishibekairohan 44:2aff0da5ebdb 1984 slow = 5;
yabahiro 46:68296caae1af 1985 }
yabahiro 46:68296caae1af 1986
yabahiro 38:40e7fdf3c694 1987 if(cross==3) {
kishibekairohan 44:2aff0da5ebdb 1988 fast=40;
kishibekairohan 44:2aff0da5ebdb 1989 normal=30;
kishibekairohan 44:2aff0da5ebdb 1990 slow=20;
yabahiro 33:dd598bb23ad1 1991 mode=11;
yabahiro 33:dd598bb23ad1 1992 countss=0;
yabahiro 33:dd598bb23ad1 1993 cross=0;
yabahiro 46:68296caae1af 1994
yabahiro 33:dd598bb23ad1 1995 }
yabahiro 33:dd598bb23ad1 1996 break;
yabahiro 33:dd598bb23ad1 1997 case 0:
kishibekairohan 44:2aff0da5ebdb 1998 motor[TIRE_FR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 1999 motor[TIRE_FR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2000 motor[TIRE_FL].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2001 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2002 motor[TIRE_BR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2003 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2004 motor[TIRE_BL].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2005 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2006 mtc=true;
yabahiro 33:dd598bb23ad1 2007 break;
yabahiro 33:dd598bb23ad1 2008 case 255:
kishibekairohan 44:2aff0da5ebdb 2009 motor[TIRE_FR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2010 motor[TIRE_FR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2011 motor[TIRE_FL].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2012 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2013 motor[TIRE_BR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2014 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2015 motor[TIRE_BL].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2016 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2017 mtc=true;
yabahiro 33:dd598bb23ad1 2018 break;
yabahiro 33:dd598bb23ad1 2019 case 253:
kishibekairohan 44:2aff0da5ebdb 2020 motor[TIRE_FR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2021 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2022 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2023 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2024 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2025 motor[TIRE_BR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2026 motor[TIRE_BL].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2027 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2028 mtc=true;
yabahiro 33:dd598bb23ad1 2029 break;
yabahiro 33:dd598bb23ad1 2030 case 254:
kishibekairohan 44:2aff0da5ebdb 2031 motor[TIRE_FR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 2032 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2033 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2034 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2035 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2036 motor[TIRE_BR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2037 motor[TIRE_BL].pwm = normal+50;
yabahiro 33:dd598bb23ad1 2038 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2039 mtc=true;
yabahiro 33:dd598bb23ad1 2040 break;
yabahiro 33:dd598bb23ad1 2041 case 1:
kishibekairohan 44:2aff0da5ebdb 2042 motor[TIRE_FR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2043 motor[TIRE_FR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2044 motor[TIRE_FL].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2045 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2046 motor[TIRE_BR].pwm = fast+50;
yabahiro 33:dd598bb23ad1 2047 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2048 motor[TIRE_BL].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2049 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2050 mtc=true;
yabahiro 33:dd598bb23ad1 2051 break;
yabahiro 33:dd598bb23ad1 2052 case 3:
yabahiro 33:dd598bb23ad1 2053 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2054 motor[TIRE_FR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2055 motor[TIRE_FL].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2056 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2057 motor[TIRE_BR].pwm = slow+50;
yabahiro 33:dd598bb23ad1 2058 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2059 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2060 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2061 mtc=true;
yabahiro 33:dd598bb23ad1 2062 break;
yabahiro 33:dd598bb23ad1 2063 case 2:
yabahiro 33:dd598bb23ad1 2064 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2065 motor[TIRE_FR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2066 motor[TIRE_FL].pwm = normal+50;
yabahiro 33:dd598bb23ad1 2067 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2068 motor[TIRE_BR].pwm = normal+50;
yabahiro 33:dd598bb23ad1 2069 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2070 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2071 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2072 mtc=true;
yabahiro 33:dd598bb23ad1 2073 break;
yabahiro 33:dd598bb23ad1 2074 }
yabahiro 33:dd598bb23ad1 2075 if(g[0]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 2076 switch(g[1]) {
yabahiro 33:dd598bb23ad1 2077 case 0:
yabahiro 33:dd598bb23ad1 2078 mtc=false;
yabahiro 33:dd598bb23ad1 2079 break;
yabahiro 33:dd598bb23ad1 2080 case 255:
kishibekairohan 44:2aff0da5ebdb 2081 motor[TIRE_BR].pwm += 3;
yabahiro 33:dd598bb23ad1 2082 mtc=false;
yabahiro 33:dd598bb23ad1 2083 break;
yabahiro 33:dd598bb23ad1 2084 case 253:
kishibekairohan 44:2aff0da5ebdb 2085 motor[TIRE_BR].pwm += 6;
yabahiro 33:dd598bb23ad1 2086 mtc=false;
yabahiro 33:dd598bb23ad1 2087 break;
yabahiro 33:dd598bb23ad1 2088 case 254:
kishibekairohan 44:2aff0da5ebdb 2089 motor[TIRE_BR].pwm += 9;
yabahiro 33:dd598bb23ad1 2090 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2091 mtc=false;
yabahiro 33:dd598bb23ad1 2092 break;
yabahiro 33:dd598bb23ad1 2093 case 1:
kishibekairohan 44:2aff0da5ebdb 2094 motor[TIRE_BL].pwm += 3;
yabahiro 33:dd598bb23ad1 2095 mtc=false;
yabahiro 33:dd598bb23ad1 2096 break;
yabahiro 33:dd598bb23ad1 2097 case 3:
kishibekairohan 44:2aff0da5ebdb 2098 motor[TIRE_BL].pwm += 6;
yabahiro 33:dd598bb23ad1 2099 mtc=false;
yabahiro 33:dd598bb23ad1 2100 break;
yabahiro 33:dd598bb23ad1 2101 case 2:
kishibekairohan 44:2aff0da5ebdb 2102 motor[TIRE_BL].pwm += 9;
yabahiro 33:dd598bb23ad1 2103 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2104 mtc=false;
yabahiro 33:dd598bb23ad1 2105 break;
yabahiro 33:dd598bb23ad1 2106 }
yabahiro 33:dd598bb23ad1 2107 }
yabahiro 46:68296caae1af 2108 } else if(mode==11) {
kishibekairohan 44:2aff0da5ebdb 2109 motor[TIRE_FR].pwm = 25;
kishibekairohan 44:2aff0da5ebdb 2110 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2111 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 2112 motor[TIRE_FL].dir = FOR;
yabahiro 33:dd598bb23ad1 2113 motor[TIRE_BR].pwm = normal;
yabahiro 33:dd598bb23ad1 2114 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2115 motor[TIRE_BL].pwm = 25;
kishibekairohan 44:2aff0da5ebdb 2116 motor[TIRE_BL].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2117 if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) {
yabahiro 33:dd598bb23ad1 2118 countss=0;
yabahiro 33:dd598bb23ad1 2119 cross=0;
yabahiro 33:dd598bb23ad1 2120 mode=20;
yabahiro 33:dd598bb23ad1 2121 }
yabahiro 46:68296caae1af 2122 } else if(mode==20) {
yabahiro 38:40e7fdf3c694 2123 solenoid.solenoid4= SOLENOID_ON;
yabahiro 33:dd598bb23ad1 2124 switch(g[2]) {
yabahiro 33:dd598bb23ad1 2125 case 98:
kishibekairohan 44:2aff0da5ebdb 2126 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2127 motor[TIRE_FR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2128 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2129 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2130 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2131 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2132 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2133 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2134 if(countss>30000) {
yabahiro 33:dd598bb23ad1 2135 cross++;
yabahiro 33:dd598bb23ad1 2136 countss=0;
yabahiro 33:dd598bb23ad1 2137 }
yabahiro 33:dd598bb23ad1 2138 mtc2=true;
yabahiro 46:68296caae1af 2139
kishibekairohan 44:2aff0da5ebdb 2140 if(YELLOW) {
kishibekairohan 44:2aff0da5ebdb 2141 if(cross==1) {
yabahiro 46:68296caae1af 2142 fast=20;
yabahiro 46:68296caae1af 2143 normal=15;
yabahiro 46:68296caae1af 2144 slow=15;
yabahiro 46:68296caae1af 2145 } else if(cross==2) {
yabahiro 38:40e7fdf3c694 2146 mode=21;
yabahiro 38:40e7fdf3c694 2147 countss=0;
yabahiro 38:40e7fdf3c694 2148 cross=0;
yabahiro 38:40e7fdf3c694 2149 }
yabahiro 38:40e7fdf3c694 2150 } else {
yabahiro 40:ed2409e0ce6b 2151 if(cross==3) {
yabahiro 38:40e7fdf3c694 2152 mode=21;
yabahiro 38:40e7fdf3c694 2153 countss=0;
yabahiro 38:40e7fdf3c694 2154 cross=0;
yabahiro 38:40e7fdf3c694 2155 }
yabahiro 38:40e7fdf3c694 2156 }
yabahiro 33:dd598bb23ad1 2157 break;
yabahiro 33:dd598bb23ad1 2158 case 0:
kishibekairohan 44:2aff0da5ebdb 2159 motor[TIRE_FR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2160 motor[TIRE_FR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2161 motor[TIRE_FL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2162 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2163 motor[TIRE_BR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2164 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2165 motor[TIRE_BL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2166 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2167 mtc2=true;
yabahiro 33:dd598bb23ad1 2168 break;
yabahiro 33:dd598bb23ad1 2169 case 255:
kishibekairohan 44:2aff0da5ebdb 2170 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2171 motor[TIRE_FR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2172 motor[TIRE_FL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2173 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2174 motor[TIRE_BR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2175 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2176 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2177 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2178 mtc2=true;
yabahiro 33:dd598bb23ad1 2179 break;
yabahiro 33:dd598bb23ad1 2180 case 253:
yabahiro 33:dd598bb23ad1 2181 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2182 motor[TIRE_FR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2183 motor[TIRE_FL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2184 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2185 motor[TIRE_BR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2186 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2187 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2188 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2189 mtc2=true;
yabahiro 33:dd598bb23ad1 2190 break;
yabahiro 33:dd598bb23ad1 2191 case 254:
yabahiro 33:dd598bb23ad1 2192 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 2193 motor[TIRE_FR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2194 motor[TIRE_FL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2195 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2196 motor[TIRE_BR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2197 motor[TIRE_BR].dir = BACK;
yabahiro 33:dd598bb23ad1 2198 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2199 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 2200 mtc2=true;
yabahiro 33:dd598bb23ad1 2201 break;
yabahiro 33:dd598bb23ad1 2202 case 1:
kishibekairohan 44:2aff0da5ebdb 2203 motor[TIRE_FR].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2204 motor[TIRE_FR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2205 motor[TIRE_FL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2206 motor[TIRE_FL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2207 motor[TIRE_BR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2208 motor[TIRE_BR].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 2209 motor[TIRE_BL].pwm = fast+20;
yabahiro 33:dd598bb23ad1 2210 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2211 mtc2=true;
yabahiro 33:dd598bb23ad1 2212 break;
yabahiro 33:dd598bb23ad1 2213 case 3:
kishibekairohan 44:2aff0da5ebdb 2214 motor[TIRE_FR].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2215 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2216 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2217 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2218 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2219 motor[TIRE_BR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2220 motor[TIRE_BL].pwm = slow+20;
yabahiro 33:dd598bb23ad1 2221 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2222 mtc2=true;
yabahiro 33:dd598bb23ad1 2223 break;
yabahiro 33:dd598bb23ad1 2224 case 2:
kishibekairohan 44:2aff0da5ebdb 2225 motor[TIRE_FR].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2226 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 2227 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2228 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 2229 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 2230 motor[TIRE_BR].dir = FREE;
kishibekairohan 44:2aff0da5ebdb 2231 motor[TIRE_BL].pwm = normal+20;
yabahiro 33:dd598bb23ad1 2232 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 2233 mtc2=true;
yabahiro 33:dd598bb23ad1 2234 break;
yabahiro 33:dd598bb23ad1 2235 }
yabahiro 33:dd598bb23ad1 2236 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 2237 switch(g[3]) {
yabahiro 33:dd598bb23ad1 2238 case 0:
yabahiro 33:dd598bb23ad1 2239 mtc2=false;
yabahiro 33:dd598bb23ad1 2240 break;
yabahiro 33:dd598bb23ad1 2241 case 255:
yabahiro 33:dd598bb23ad1 2242 motor[TIRE_BL].pwm += 5;
yabahiro 33:dd598bb23ad1 2243 mtc2=false;
yabahiro 33:dd598bb23ad1 2244 break;
yabahiro 33:dd598bb23ad1 2245 case 253:
yabahiro 33:dd598bb23ad1 2246 motor[TIRE_BL].pwm += 10;
yabahiro 33:dd598bb23ad1 2247 mtc2=false;
yabahiro 33:dd598bb23ad1 2248 break;
yabahiro 33:dd598bb23ad1 2249 case 254:
kishibekairohan 44:2aff0da5ebdb 2250 motor[TIRE_BL].pwm += 15;
yabahiro 33:dd598bb23ad1 2251 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 2252 mtc2=false;
yabahiro 33:dd598bb23ad1 2253 break;
yabahiro 33:dd598bb23ad1 2254 case 1:
yabahiro 33:dd598bb23ad1 2255 motor[TIRE_FL].pwm += 5;
yabahiro 33:dd598bb23ad1 2256 mtc2=false;
yabahiro 33:dd598bb23ad1 2257 break;
yabahiro 33:dd598bb23ad1 2258 case 3:
yabahiro 33:dd598bb23ad1 2259 motor[TIRE_FL].pwm += 10;
yabahiro 33:dd598bb23ad1 2260 mtc2=false;
yabahiro 33:dd598bb23ad1 2261 break;
yabahiro 33:dd598bb23ad1 2262 case 2:
kishibekairohan 44:2aff0da5ebdb 2263 motor[TIRE_FL].pwm += 15;
yabahiro 33:dd598bb23ad1 2264 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 2265 mtc2=false;
yabahiro 33:dd598bb23ad1 2266 break;
yabahiro 33:dd598bb23ad1 2267 }
yabahiro 33:dd598bb23ad1 2268 }
yabahiro 33:dd598bb23ad1 2269 }
yabahiro 38:40e7fdf3c694 2270 if(YELLOW) {
yabahiro 38:40e7fdf3c694 2271 if(mode==21) {
yabahiro 33:dd598bb23ad1 2272 motor[TIRE_FR].pwm = 20;
yabahiro 33:dd598bb23ad1 2273 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 2274 motor[TIRE_FL].pwm = 20;
yabahiro 33:dd598bb23ad1 2275 motor[TIRE_FL].dir = BACK;
yabahiro 33:dd598bb23ad1 2276 motor[TIRE_BR].pwm = 20;
yabahiro 33:dd598bb23ad1 2277 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 2278 motor[TIRE_BL].pwm = 20;
yabahiro 33:dd598bb23ad1 2279 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2280 if(g[3]==98&&countss>=10000) {
yabahiro 38:40e7fdf3c694 2281 mode=22;
yabahiro 33:dd598bb23ad1 2282 countss=0;
yabahiro 38:40e7fdf3c694 2283 fast=60;
yabahiro 38:40e7fdf3c694 2284 normal=40;
yabahiro 38:40e7fdf3c694 2285 slow=20;
yabahiro 38:40e7fdf3c694 2286 }
yabahiro 46:68296caae1af 2287 } else if(mode==22) {
yabahiro 38:40e7fdf3c694 2288 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 2289 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2290 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2291 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2292 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2293 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2294 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2295 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2296 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2297 }
yabahiro 38:40e7fdf3c694 2298 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 2299 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2300 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2301 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2302 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2303 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2304 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2305 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2306 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 2307 }
yabahiro 38:40e7fdf3c694 2308 switch(g[2]) {
yabahiro 38:40e7fdf3c694 2309 case 0:
yabahiro 38:40e7fdf3c694 2310 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2311 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2312 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2313 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2314 break;
yabahiro 38:40e7fdf3c694 2315 case 255:
yabahiro 38:40e7fdf3c694 2316 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2317 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2318 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2319 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2320 break;
yabahiro 38:40e7fdf3c694 2321 case 253:
yabahiro 38:40e7fdf3c694 2322 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2323 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2324 motor[TIRE_BR].pwm = 20;
yabahiro 38:40e7fdf3c694 2325 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2326 break;
yabahiro 38:40e7fdf3c694 2327 case 254:
yabahiro 38:40e7fdf3c694 2328 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2329 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2330 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2331 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2332 break;
yabahiro 38:40e7fdf3c694 2333 case 1:
yabahiro 38:40e7fdf3c694 2334 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2335 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2336 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2337 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2338 break;
yabahiro 38:40e7fdf3c694 2339 case 3:
yabahiro 38:40e7fdf3c694 2340 motor[TIRE_FR].pwm = 20;
yabahiro 38:40e7fdf3c694 2341 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2342 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2343 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2344 break;
yabahiro 38:40e7fdf3c694 2345 case 2:
yabahiro 38:40e7fdf3c694 2346 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2347 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2348 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2349 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2350 break;
yabahiro 38:40e7fdf3c694 2351 }
yabahiro 38:40e7fdf3c694 2352 switch(g[3]) {
yabahiro 38:40e7fdf3c694 2353 case 0:
yabahiro 38:40e7fdf3c694 2354 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2355 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2356 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2357 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2358 break;
yabahiro 38:40e7fdf3c694 2359 case 255:
yabahiro 38:40e7fdf3c694 2360 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2361 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2362 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2363 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2364 case 253:
yabahiro 38:40e7fdf3c694 2365 motor[TIRE_FL].pwm = 20;
yabahiro 38:40e7fdf3c694 2366 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2367 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2368 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2369 break;
yabahiro 38:40e7fdf3c694 2370 case 254:
yabahiro 38:40e7fdf3c694 2371 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2372 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2373 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2374 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2375 break;
yabahiro 38:40e7fdf3c694 2376 case 1:
yabahiro 38:40e7fdf3c694 2377 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2378 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2379 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2380 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2381 break;
yabahiro 38:40e7fdf3c694 2382 case 3:
yabahiro 38:40e7fdf3c694 2383 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2384 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2385 motor[TIRE_BL].pwm = 20;
yabahiro 38:40e7fdf3c694 2386 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2387 break;
yabahiro 38:40e7fdf3c694 2388 case 2:
yabahiro 38:40e7fdf3c694 2389 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2390 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2391 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2392 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2393 break;
yabahiro 38:40e7fdf3c694 2394 }
yabahiro 38:40e7fdf3c694 2395 if(g[3]==0&&g[2]==0) {
yabahiro 38:40e7fdf3c694 2396 mode=23;
yabahiro 33:dd598bb23ad1 2397 countss=0;
yabahiro 33:dd598bb23ad1 2398 }
yabahiro 46:68296caae1af 2399 } else if(mode==23) {
yabahiro 38:40e7fdf3c694 2400 switch(g[4]) {
yabahiro 38:40e7fdf3c694 2401 case 98:
kishibekairohan 41:99a1158f3eca 2402 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2403 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2404 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2405 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2406 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2407 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2408 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2409 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2410 break;
yabahiro 38:40e7fdf3c694 2411 case 99:
yabahiro 38:40e7fdf3c694 2412 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2413 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2414 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2415 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2416 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2417 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2418 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2419 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2420 break;
yabahiro 38:40e7fdf3c694 2421 case 0:
kishibekairohan 41:99a1158f3eca 2422 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2423 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2424 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2425 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2426 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2427 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2428 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2429 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2430 break;
yabahiro 38:40e7fdf3c694 2431 case 255:
yabahiro 38:40e7fdf3c694 2432 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2433 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2434 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2435 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2436 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2437 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2438 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2439 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2440 break;
yabahiro 38:40e7fdf3c694 2441 case 253:
yabahiro 46:68296caae1af 2442 motor[TIRE_FR].pwm = slow+5;
yabahiro 38:40e7fdf3c694 2443 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2444 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2445 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2446 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2447 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 2448 motor[TIRE_BL].pwm = slow+5;
yabahiro 38:40e7fdf3c694 2449 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2450 break;
yabahiro 38:40e7fdf3c694 2451 case 254:
yabahiro 46:68296caae1af 2452 motor[TIRE_FR].pwm = normal+5;
yabahiro 38:40e7fdf3c694 2453 motor[TIRE_FR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2454 motor[TIRE_FL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2455 motor[TIRE_FL].dir = BACK;
kishibekairohan 41:99a1158f3eca 2456 motor[TIRE_BR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2457 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 2458 motor[TIRE_BL].pwm = normal+5;
yabahiro 38:40e7fdf3c694 2459 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2460 break;
yabahiro 38:40e7fdf3c694 2461 case 1:
yabahiro 38:40e7fdf3c694 2462 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2463 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2464 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2465 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2466 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2467 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2468 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2469 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2470 break;
yabahiro 38:40e7fdf3c694 2471 case 3:
kishibekairohan 41:99a1158f3eca 2472 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2473 motor[TIRE_FR].dir = FOR;
yabahiro 46:68296caae1af 2474 motor[TIRE_FL].pwm = slow+5;
yabahiro 38:40e7fdf3c694 2475 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 2476 motor[TIRE_BR].pwm = slow+5;
yabahiro 38:40e7fdf3c694 2477 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2478 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2479 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2480 break;
yabahiro 38:40e7fdf3c694 2481 case 2:
kishibekairohan 41:99a1158f3eca 2482 motor[TIRE_FR].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2483 motor[TIRE_FR].dir = FOR;
yabahiro 46:68296caae1af 2484 motor[TIRE_FL].pwm = normal+5;
yabahiro 38:40e7fdf3c694 2485 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 2486 motor[TIRE_BR].pwm = normal+5;
yabahiro 38:40e7fdf3c694 2487 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2488 motor[TIRE_BL].pwm = fast-5;
yabahiro 38:40e7fdf3c694 2489 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2490 break;
yabahiro 33:dd598bb23ad1 2491 }
yabahiro 38:40e7fdf3c694 2492 if(g[1]==98) {
kishibekairohan 42:980af34f6fe3 2493 fast=20;
kishibekairohan 42:980af34f6fe3 2494 normal=15;
kishibekairohan 42:980af34f6fe3 2495 slow=10;
yabahiro 38:40e7fdf3c694 2496 }
yabahiro 38:40e7fdf3c694 2497 if(g[3]==254&&countss>=100000) {
yabahiro 38:40e7fdf3c694 2498 mode=24;
yabahiro 38:40e7fdf3c694 2499 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 2500 countss=0;
yabahiro 38:40e7fdf3c694 2501 fast=60;
yabahiro 38:40e7fdf3c694 2502 normal=40;
kishibekairohan 42:980af34f6fe3 2503 slow=20;
yabahiro 33:dd598bb23ad1 2504 }
yabahiro 46:68296caae1af 2505 } else if(mode==24) {
yabahiro 38:40e7fdf3c694 2506 if(g[4]==3||g[4]==2) {
yabahiro 38:40e7fdf3c694 2507 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2508 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2509 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2510 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2511 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2512 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2513 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2514 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2515 }
yabahiro 38:40e7fdf3c694 2516 if(g[4]==253||g[4]==254) {
yabahiro 38:40e7fdf3c694 2517 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2518 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2519 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2520 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2521 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2522 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2523 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2524 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2525 }
yabahiro 38:40e7fdf3c694 2526 switch(g[2]) {
yabahiro 38:40e7fdf3c694 2527 case 0:
yabahiro 46:68296caae1af 2528 motor[TIRE_FR].pwm = 25;
yabahiro 38:40e7fdf3c694 2529 motor[TIRE_FR].dir = FREE;
yabahiro 46:68296caae1af 2530 motor[TIRE_BR].pwm = 25;
yabahiro 38:40e7fdf3c694 2531 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2532 break;
yabahiro 38:40e7fdf3c694 2533 case 255:
yabahiro 38:40e7fdf3c694 2534 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2535 motor[TIRE_FR].dir = BACK;
yabahiro 46:68296caae1af 2536 motor[TIRE_BR].pwm = 25;
yabahiro 38:40e7fdf3c694 2537 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2538 break;
yabahiro 38:40e7fdf3c694 2539 case 253:
yabahiro 38:40e7fdf3c694 2540 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2541 motor[TIRE_FR].dir = BACK;
yabahiro 46:68296caae1af 2542 motor[TIRE_BR].pwm = 25;
yabahiro 38:40e7fdf3c694 2543 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2544 break;
yabahiro 38:40e7fdf3c694 2545 case 254:
yabahiro 38:40e7fdf3c694 2546 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2547 motor[TIRE_FR].dir = BACK;
yabahiro 38:40e7fdf3c694 2548 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2549 motor[TIRE_BR].dir = BACK;
yabahiro 38:40e7fdf3c694 2550 break;
yabahiro 38:40e7fdf3c694 2551 case 1:
yabahiro 46:68296caae1af 2552 motor[TIRE_FR].pwm = 25;
yabahiro 38:40e7fdf3c694 2553 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2554 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2555 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2556 break;
yabahiro 38:40e7fdf3c694 2557 case 3:
yabahiro 46:68296caae1af 2558 motor[TIRE_FR].pwm = 25;
yabahiro 38:40e7fdf3c694 2559 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2560 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2561 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2562 break;
yabahiro 38:40e7fdf3c694 2563 case 2:
yabahiro 38:40e7fdf3c694 2564 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2565 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2566 motor[TIRE_BR].pwm = 30;
yabahiro 38:40e7fdf3c694 2567 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2568 break;
yabahiro 38:40e7fdf3c694 2569 }
yabahiro 38:40e7fdf3c694 2570 switch(g[3]) {
yabahiro 38:40e7fdf3c694 2571 case 0:
yabahiro 46:68296caae1af 2572 motor[TIRE_FL].pwm = 25;
yabahiro 38:40e7fdf3c694 2573 motor[TIRE_FL].dir = FREE;
yabahiro 46:68296caae1af 2574 motor[TIRE_BL].pwm = 25;
yabahiro 38:40e7fdf3c694 2575 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2576 break;
yabahiro 38:40e7fdf3c694 2577 case 255:
yabahiro 46:68296caae1af 2578 motor[TIRE_FL].pwm = 25;
yabahiro 38:40e7fdf3c694 2579 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2580 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2581 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2582 case 253:
yabahiro 46:68296caae1af 2583 motor[TIRE_FL].pwm = 25;
yabahiro 38:40e7fdf3c694 2584 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2585 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2586 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2587 break;
yabahiro 38:40e7fdf3c694 2588 case 254:
yabahiro 38:40e7fdf3c694 2589 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2590 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2591 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2592 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2593 break;
yabahiro 38:40e7fdf3c694 2594 case 1:
yabahiro 38:40e7fdf3c694 2595 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2596 motor[TIRE_FL].dir = FOR;
yabahiro 46:68296caae1af 2597 motor[TIRE_BL].pwm = 25;
yabahiro 38:40e7fdf3c694 2598 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2599 break;
yabahiro 38:40e7fdf3c694 2600 case 3:
yabahiro 38:40e7fdf3c694 2601 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2602 motor[TIRE_FL].dir = FOR;
yabahiro 46:68296caae1af 2603 motor[TIRE_BL].pwm = 25;
yabahiro 38:40e7fdf3c694 2604 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2605 break;
yabahiro 38:40e7fdf3c694 2606 case 2:
yabahiro 38:40e7fdf3c694 2607 motor[TIRE_FL].pwm = 30;
yabahiro 38:40e7fdf3c694 2608 motor[TIRE_FL].dir = FOR;
yabahiro 38:40e7fdf3c694 2609 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2610 motor[TIRE_BL].dir = FOR;
yabahiro 38:40e7fdf3c694 2611 break;
yabahiro 38:40e7fdf3c694 2612 }
yabahiro 38:40e7fdf3c694 2613 if(g[3]==0&&g[2]==0) {
yabahiro 46:68296caae1af 2614 mode=25;
yabahiro 38:40e7fdf3c694 2615 }
yabahiro 46:68296caae1af 2616 } else if(mode==25) {
kishibekairohan 47:a9cad8502999 2617 motor[TIRE_FR].pwm = 100;
kishibekairohan 47:a9cad8502999 2618 motor[TIRE_FR].dir = BRAKE;
kishibekairohan 47:a9cad8502999 2619 motor[TIRE_FL].pwm = 100;
kishibekairohan 47:a9cad8502999 2620 motor[TIRE_FL].dir = BRAKE;
kishibekairohan 47:a9cad8502999 2621 motor[TIRE_BR].pwm = 100;
kishibekairohan 47:a9cad8502999 2622 motor[TIRE_BR].dir = BRAKE;
kishibekairohan 47:a9cad8502999 2623 motor[TIRE_BL].pwm = 100;
kishibekairohan 47:a9cad8502999 2624 motor[TIRE_BL].dir = BRAKE;
yabahiro 46:68296caae1af 2625 if(UPLS==true||DOLS==true) {
yabahiro 46:68296caae1af 2626 motor[MOTOR_0].pwm = 200;
yabahiro 46:68296caae1af 2627 motor[MOTOR_0].dir = BRAKE;
yabahiro 46:68296caae1af 2628 mode=26;
yabahiro 46:68296caae1af 2629 } else {
yabahiro 46:68296caae1af 2630 motor[MOTOR_0].pwm = 100;
yabahiro 46:68296caae1af 2631 motor[MOTOR_0].dir = BACK;
yabahiro 46:68296caae1af 2632 }
yabahiro 46:68296caae1af 2633 } else if(mode==26) {
yabahiro 38:40e7fdf3c694 2634 switch(g[4]) {
yabahiro 38:40e7fdf3c694 2635 case 98:
yabahiro 38:40e7fdf3c694 2636 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2637 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2638 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2639 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2640 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2641 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2642 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2643 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2644 break;
yabahiro 38:40e7fdf3c694 2645 case 99:
yabahiro 38:40e7fdf3c694 2646 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2647 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2648 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2649 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2650 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2651 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2652 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2653 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2654 break;
yabahiro 38:40e7fdf3c694 2655 case 0:
yabahiro 38:40e7fdf3c694 2656 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2657 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2658 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2659 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2660 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2661 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2662 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2663 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2664 break;
yabahiro 38:40e7fdf3c694 2665 case 255:
yabahiro 38:40e7fdf3c694 2666 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2667 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2668 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2669 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2670 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2671 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2672 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2673 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2674 break;
yabahiro 38:40e7fdf3c694 2675 case 253:
yabahiro 46:68296caae1af 2676 motor[TIRE_FR].pwm = 25;
yabahiro 38:40e7fdf3c694 2677 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2678 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2679 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2680 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2681 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 2682 motor[TIRE_BL].pwm = 25;
yabahiro 38:40e7fdf3c694 2683 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2684 break;
yabahiro 38:40e7fdf3c694 2685 case 254:
yabahiro 38:40e7fdf3c694 2686 motor[TIRE_FR].pwm = 40;
yabahiro 38:40e7fdf3c694 2687 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2688 motor[TIRE_FL].pwm = 60;
yabahiro 38:40e7fdf3c694 2689 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2690 motor[TIRE_BR].pwm = 60;
yabahiro 38:40e7fdf3c694 2691 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2692 motor[TIRE_BL].pwm = 40;
yabahiro 38:40e7fdf3c694 2693 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2694 break;
yabahiro 38:40e7fdf3c694 2695 case 1:
yabahiro 38:40e7fdf3c694 2696 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2697 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2698 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2699 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2700 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2701 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2702 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2703 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2704 break;
yabahiro 38:40e7fdf3c694 2705 case 3:
yabahiro 38:40e7fdf3c694 2706 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2707 motor[TIRE_FR].dir = FOR;
yabahiro 46:68296caae1af 2708 motor[TIRE_FL].pwm = 25;
yabahiro 38:40e7fdf3c694 2709 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 2710 motor[TIRE_BR].pwm = 25;
yabahiro 38:40e7fdf3c694 2711 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2712 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2713 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2714 break;
yabahiro 38:40e7fdf3c694 2715 case 2:
yabahiro 38:40e7fdf3c694 2716 motor[TIRE_FR].pwm = 60;
yabahiro 38:40e7fdf3c694 2717 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2718 motor[TIRE_FL].pwm = 40;
yabahiro 38:40e7fdf3c694 2719 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2720 motor[TIRE_BR].pwm = 40;
yabahiro 38:40e7fdf3c694 2721 motor[TIRE_BR].dir = FOR;
kishibekairohan 41:99a1158f3eca 2722 motor[TIRE_BL].pwm = 60;
yabahiro 38:40e7fdf3c694 2723 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2724 break;
yabahiro 38:40e7fdf3c694 2725 }
yabahiro 38:40e7fdf3c694 2726 if(g[1]==98) {
kishibekairohan 45:0cf48a0605cd 2727 mode=31;
yabahiro 33:dd598bb23ad1 2728 }
yabahiro 33:dd598bb23ad1 2729 }
yabahiro 46:68296caae1af 2730 } else {
yabahiro 38:40e7fdf3c694 2731 if(mode==21) {
yabahiro 38:40e7fdf3c694 2732 motor[TIRE_FR].pwm = 30;
yabahiro 38:40e7fdf3c694 2733 motor[TIRE_FR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 2734 motor[TIRE_FL].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 2735 motor[TIRE_FL].dir = BRAKE;
kishibekairohan 44:2aff0da5ebdb 2736 motor[TIRE_BR].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 2737 motor[TIRE_BR].dir = BRAKE;
yabahiro 38:40e7fdf3c694 2738 motor[TIRE_BL].pwm = 30;
yabahiro 38:40e7fdf3c694 2739 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2740 if(g[1]==0) {
yabahiro 38:40e7fdf3c694 2741 mode=22;
yabahiro 38:40e7fdf3c694 2742 fast=60;
yabahiro 38:40e7fdf3c694 2743 normal=40;
yabahiro 46:68296caae1af 2744 slow=25;
yabahiro 38:40e7fdf3c694 2745 }
yabahiro 46:68296caae1af 2746 } else if(mode==22) {
yabahiro 40:ed2409e0ce6b 2747 if(g[1]==98) {
yabahiro 46:68296caae1af 2748 slow=25;
kishibekairohan 44:2aff0da5ebdb 2749 normal=30;
kishibekairohan 44:2aff0da5ebdb 2750 fast=40;
yabahiro 40:ed2409e0ce6b 2751 }
yabahiro 46:68296caae1af 2752 if(g[3]==0) {
yabahiro 46:68296caae1af 2753 slow=25;
yabahiro 40:ed2409e0ce6b 2754 normal=40;
yabahiro 40:ed2409e0ce6b 2755 fast=60;
yabahiro 38:40e7fdf3c694 2756 mode=23;
yabahiro 46:68296caae1af 2757 }
yabahiro 38:40e7fdf3c694 2758 switch(g[1]) {
yabahiro 38:40e7fdf3c694 2759 case 98:
yabahiro 38:40e7fdf3c694 2760 solenoid.solenoid4 = SOLENOID_OFF;
kishibekairohan 44:2aff0da5ebdb 2761 fast=40;
kishibekairohan 44:2aff0da5ebdb 2762 normal=30;
yabahiro 46:68296caae1af 2763 slow=25;
yabahiro 38:40e7fdf3c694 2764 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2765 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2766 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2767 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2768 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2769 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2770 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2771 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2772 break;
yabahiro 38:40e7fdf3c694 2773 case 0:
yabahiro 38:40e7fdf3c694 2774 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2775 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2776 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2777 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2778 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2779 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2780 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2781 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2782 mtc=true;
yabahiro 38:40e7fdf3c694 2783 break;
yabahiro 38:40e7fdf3c694 2784 case 255:
yabahiro 38:40e7fdf3c694 2785 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2786 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2787 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2788 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2789 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2790 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2791 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2792 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2793 mtc=true;
yabahiro 38:40e7fdf3c694 2794 break;
yabahiro 38:40e7fdf3c694 2795 case 253:
yabahiro 38:40e7fdf3c694 2796 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2797 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2798 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2799 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2800 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2801 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2802 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2803 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2804 mtc=true;
yabahiro 38:40e7fdf3c694 2805 break;
yabahiro 38:40e7fdf3c694 2806 case 254:
yabahiro 38:40e7fdf3c694 2807 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2808 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2809 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2810 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2811 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2812 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2813 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2814 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2815 mtc=true;
yabahiro 38:40e7fdf3c694 2816 break;
yabahiro 38:40e7fdf3c694 2817 case 1:
yabahiro 38:40e7fdf3c694 2818 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2819 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2820 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2821 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2822 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2823 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2824 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2825 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2826 mtc=true;
yabahiro 38:40e7fdf3c694 2827 break;
yabahiro 38:40e7fdf3c694 2828 case 3:
yabahiro 38:40e7fdf3c694 2829 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2830 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2831 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2832 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2833 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2834 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2835 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2836 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2837 mtc=true;
yabahiro 38:40e7fdf3c694 2838 break;
yabahiro 38:40e7fdf3c694 2839 case 2:
yabahiro 38:40e7fdf3c694 2840 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2841 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2842 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2843 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2844 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2845 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2846 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2847 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2848 mtc=true;
yabahiro 38:40e7fdf3c694 2849 break;
yabahiro 38:40e7fdf3c694 2850 }
yabahiro 38:40e7fdf3c694 2851 if(g[1]!=98&&mtc==true) {
yabahiro 38:40e7fdf3c694 2852 switch(g[0]) {
yabahiro 38:40e7fdf3c694 2853 case 0:
yabahiro 38:40e7fdf3c694 2854 mtc=false;
yabahiro 38:40e7fdf3c694 2855 break;
yabahiro 38:40e7fdf3c694 2856 case 255:
kishibekairohan 44:2aff0da5ebdb 2857 motor[TIRE_FL].pwm += 3;
yabahiro 38:40e7fdf3c694 2858 mtc=false;
yabahiro 38:40e7fdf3c694 2859 break;
yabahiro 38:40e7fdf3c694 2860 case 253:
kishibekairohan 44:2aff0da5ebdb 2861 motor[TIRE_FL].pwm += 6;
yabahiro 38:40e7fdf3c694 2862 mtc=false;
yabahiro 38:40e7fdf3c694 2863 break;
yabahiro 38:40e7fdf3c694 2864 case 254:
kishibekairohan 44:2aff0da5ebdb 2865 motor[TIRE_FL].pwm += 9;
yabahiro 38:40e7fdf3c694 2866 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2867 mtc=false;
yabahiro 38:40e7fdf3c694 2868 break;
yabahiro 38:40e7fdf3c694 2869 case 1:
kishibekairohan 44:2aff0da5ebdb 2870 motor[TIRE_FR].pwm += 3;
yabahiro 38:40e7fdf3c694 2871 mtc=false;
yabahiro 38:40e7fdf3c694 2872 break;
yabahiro 38:40e7fdf3c694 2873 case 3:
kishibekairohan 44:2aff0da5ebdb 2874 motor[TIRE_FR].pwm += 6;
yabahiro 38:40e7fdf3c694 2875 mtc=false;
yabahiro 38:40e7fdf3c694 2876 break;
yabahiro 38:40e7fdf3c694 2877 case 2:
kishibekairohan 44:2aff0da5ebdb 2878 motor[TIRE_FR].pwm += 9;
yabahiro 38:40e7fdf3c694 2879 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2880 mtc=false;
yabahiro 38:40e7fdf3c694 2881 break;
yabahiro 38:40e7fdf3c694 2882 }
yabahiro 38:40e7fdf3c694 2883 }
yabahiro 46:68296caae1af 2884 } else if(mode==23) {
yabahiro 46:68296caae1af 2885 if(UPLS||DOLS) {
yabahiro 46:68296caae1af 2886 if(UPLS||DOLS) {
yabahiro 46:68296caae1af 2887 motor[MOTOR_0].pwm = 200;
yabahiro 46:68296caae1af 2888 motor[MOTOR_0].dir = BRAKE;
yabahiro 46:68296caae1af 2889 fast=60;
yabahiro 46:68296caae1af 2890 normal=40;
yabahiro 46:68296caae1af 2891 slow=25;
yabahiro 46:68296caae1af 2892 countss=0;
yabahiro 46:68296caae1af 2893 mode=24;
yabahiro 46:68296caae1af 2894 }
yabahiro 46:68296caae1af 2895 } else {
yabahiro 38:40e7fdf3c694 2896 motor[MOTOR_0].pwm = 100;
yabahiro 38:40e7fdf3c694 2897 motor[MOTOR_0].dir = BACK;
yabahiro 38:40e7fdf3c694 2898 }
yabahiro 40:ed2409e0ce6b 2899 motor[TIRE_FR].pwm = 100;
yabahiro 40:ed2409e0ce6b 2900 motor[TIRE_FR].dir = BRAKE;
yabahiro 40:ed2409e0ce6b 2901 motor[TIRE_FL].pwm = 100;
yabahiro 40:ed2409e0ce6b 2902 motor[TIRE_FL].dir = BRAKE;
yabahiro 40:ed2409e0ce6b 2903 motor[TIRE_BR].pwm = 100;
yabahiro 40:ed2409e0ce6b 2904 motor[TIRE_BR].dir = BRAKE;
yabahiro 40:ed2409e0ce6b 2905 motor[TIRE_BL].pwm = 100;
yabahiro 40:ed2409e0ce6b 2906 motor[TIRE_BL].dir = BRAKE;
yabahiro 46:68296caae1af 2907 } else if(mode==24) {
yabahiro 38:40e7fdf3c694 2908 if(g[1]==98&&countss>=40000) {
kishibekairohan 45:0cf48a0605cd 2909 mode=31;
yabahiro 38:40e7fdf3c694 2910 countss=0;
yabahiro 38:40e7fdf3c694 2911 }
yabahiro 38:40e7fdf3c694 2912 switch(g[1]) {
yabahiro 38:40e7fdf3c694 2913 case 98:
kishibekairohan 44:2aff0da5ebdb 2914 fast=40;
kishibekairohan 44:2aff0da5ebdb 2915 normal=30;
yabahiro 46:68296caae1af 2916 slow=25;
yabahiro 38:40e7fdf3c694 2917 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2918 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2919 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2920 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2921 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2922 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2923 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2924 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2925 break;
yabahiro 38:40e7fdf3c694 2926 case 0:
yabahiro 38:40e7fdf3c694 2927 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2928 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2929 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2930 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2931 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2932 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2933 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2934 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2935 mtc=true;
yabahiro 38:40e7fdf3c694 2936 break;
yabahiro 38:40e7fdf3c694 2937 case 255:
yabahiro 38:40e7fdf3c694 2938 motor[TIRE_FR].pwm = fast;
yabahiro 38:40e7fdf3c694 2939 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2940 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2941 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2942 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2943 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2944 motor[TIRE_BL].pwm = fast;
yabahiro 38:40e7fdf3c694 2945 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2946 mtc=true;
yabahiro 38:40e7fdf3c694 2947 break;
yabahiro 38:40e7fdf3c694 2948 case 253:
yabahiro 38:40e7fdf3c694 2949 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2950 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2951 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2952 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2953 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2954 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2955 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2956 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2957 mtc=true;
yabahiro 38:40e7fdf3c694 2958 break;
yabahiro 38:40e7fdf3c694 2959 case 254:
yabahiro 38:40e7fdf3c694 2960 motor[TIRE_FR].pwm = normal;
yabahiro 38:40e7fdf3c694 2961 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2962 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 2963 motor[TIRE_FL].dir = FREE;
yabahiro 38:40e7fdf3c694 2964 motor[TIRE_BR].pwm = 0;
yabahiro 38:40e7fdf3c694 2965 motor[TIRE_BR].dir = FREE;
yabahiro 38:40e7fdf3c694 2966 motor[TIRE_BL].pwm = normal;
yabahiro 38:40e7fdf3c694 2967 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2968 mtc=true;
yabahiro 38:40e7fdf3c694 2969 break;
yabahiro 38:40e7fdf3c694 2970 case 1:
yabahiro 38:40e7fdf3c694 2971 motor[TIRE_FR].pwm = slow;
yabahiro 38:40e7fdf3c694 2972 motor[TIRE_FR].dir = FOR;
yabahiro 38:40e7fdf3c694 2973 motor[TIRE_FL].pwm = fast;
yabahiro 38:40e7fdf3c694 2974 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2975 motor[TIRE_BR].pwm = fast;
yabahiro 38:40e7fdf3c694 2976 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2977 motor[TIRE_BL].pwm = slow;
yabahiro 38:40e7fdf3c694 2978 motor[TIRE_BL].dir = BACK;
yabahiro 38:40e7fdf3c694 2979 mtc=true;
yabahiro 38:40e7fdf3c694 2980 break;
yabahiro 38:40e7fdf3c694 2981 case 3:
yabahiro 38:40e7fdf3c694 2982 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2983 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2984 motor[TIRE_FL].pwm = slow;
yabahiro 38:40e7fdf3c694 2985 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2986 motor[TIRE_BR].pwm = slow;
yabahiro 38:40e7fdf3c694 2987 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2988 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 2989 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 2990 mtc=true;
yabahiro 38:40e7fdf3c694 2991 break;
yabahiro 38:40e7fdf3c694 2992 case 2:
yabahiro 38:40e7fdf3c694 2993 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 2994 motor[TIRE_FR].dir = FREE;
yabahiro 38:40e7fdf3c694 2995 motor[TIRE_FL].pwm = normal;
yabahiro 38:40e7fdf3c694 2996 motor[TIRE_FL].dir = BACK;
yabahiro 38:40e7fdf3c694 2997 motor[TIRE_BR].pwm = normal;
yabahiro 38:40e7fdf3c694 2998 motor[TIRE_BR].dir = FOR;
yabahiro 38:40e7fdf3c694 2999 motor[TIRE_BL].pwm = 0;
yabahiro 38:40e7fdf3c694 3000 motor[TIRE_BL].dir = FREE;
yabahiro 38:40e7fdf3c694 3001 mtc=true;
yabahiro 38:40e7fdf3c694 3002 break;
yabahiro 38:40e7fdf3c694 3003 }
yabahiro 38:40e7fdf3c694 3004 if(g[1]!=98&&mtc==true) {
yabahiro 38:40e7fdf3c694 3005 switch(g[0]) {
yabahiro 38:40e7fdf3c694 3006 case 0:
yabahiro 38:40e7fdf3c694 3007 mtc=false;
yabahiro 38:40e7fdf3c694 3008 break;
yabahiro 38:40e7fdf3c694 3009 case 255:
kishibekairohan 44:2aff0da5ebdb 3010 motor[TIRE_FL].pwm += 3;
yabahiro 38:40e7fdf3c694 3011 mtc=false;
yabahiro 38:40e7fdf3c694 3012 break;
yabahiro 38:40e7fdf3c694 3013 case 253:
kishibekairohan 44:2aff0da5ebdb 3014 motor[TIRE_FL].pwm += 6;
yabahiro 38:40e7fdf3c694 3015 mtc=false;
yabahiro 38:40e7fdf3c694 3016 break;
yabahiro 38:40e7fdf3c694 3017 case 254:
kishibekairohan 44:2aff0da5ebdb 3018 motor[TIRE_FL].pwm += 9;
yabahiro 38:40e7fdf3c694 3019 motor[TIRE_FR].pwm = 0;
yabahiro 38:40e7fdf3c694 3020 mtc=false;
yabahiro 38:40e7fdf3c694 3021 break;
yabahiro 38:40e7fdf3c694 3022 case 1:
kishibekairohan 44:2aff0da5ebdb 3023 motor[TIRE_FR].pwm += 3;
yabahiro 38:40e7fdf3c694 3024 mtc=false;
yabahiro 38:40e7fdf3c694 3025 break;
yabahiro 38:40e7fdf3c694 3026 case 3:
kishibekairohan 44:2aff0da5ebdb 3027 motor[TIRE_FR].pwm += 6;
yabahiro 38:40e7fdf3c694 3028 mtc=false;
yabahiro 38:40e7fdf3c694 3029 break;
yabahiro 38:40e7fdf3c694 3030 case 2:
kishibekairohan 44:2aff0da5ebdb 3031 motor[TIRE_FR].pwm += 9;
yabahiro 38:40e7fdf3c694 3032 motor[TIRE_FL].pwm = 0;
yabahiro 38:40e7fdf3c694 3033 mtc=false;
yabahiro 38:40e7fdf3c694 3034 break;
yabahiro 38:40e7fdf3c694 3035 }
yabahiro 33:dd598bb23ad1 3036 }
yabahiro 33:dd598bb23ad1 3037 }
yabahiro 33:dd598bb23ad1 3038 }
yabahiro 46:68296caae1af 3039
kishibekairohan 44:2aff0da5ebdb 3040 /*
yabahiro 38:40e7fdf3c694 3041 if(mode==31) {
yabahiro 33:dd598bb23ad1 3042 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3043 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3044 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3045 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3046 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3047 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3048 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3049 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3050 if(countss>=5000) {
yabahiro 33:dd598bb23ad1 3051 countss=0;
yabahiro 33:dd598bb23ad1 3052 mode=32;
yabahiro 33:dd598bb23ad1 3053 }
yabahiro 33:dd598bb23ad1 3054 } else if(mode==32) {
yabahiro 33:dd598bb23ad1 3055 motor[TIRE_FR].pwm = 10;
yabahiro 33:dd598bb23ad1 3056 motor[TIRE_FR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3057 motor[TIRE_FL].pwm = 10;
yabahiro 33:dd598bb23ad1 3058 motor[TIRE_FL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3059 motor[TIRE_BR].pwm = 10;
yabahiro 33:dd598bb23ad1 3060 motor[TIRE_BR].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3061 motor[TIRE_BL].pwm = 10;
yabahiro 33:dd598bb23ad1 3062 motor[TIRE_BL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3063 if(countss>=40000) {
yabahiro 33:dd598bb23ad1 3064 mode=33;
yabahiro 33:dd598bb23ad1 3065 countss=0;
yabahiro 33:dd598bb23ad1 3066 }
yabahiro 46:68296caae1af 3067 }
kishibekairohan 44:2aff0da5ebdb 3068 */
kishibekairohan 45:0cf48a0605cd 3069 if(mode==31) {
kishibekairohan 44:2aff0da5ebdb 3070 motor[TIRE_FR].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 3071 motor[TIRE_FR].dir = BRAKE;
kishibekairohan 44:2aff0da5ebdb 3072 motor[TIRE_FL].pwm = 45;
yabahiro 38:40e7fdf3c694 3073 motor[TIRE_FL].dir = BACK;
kishibekairohan 44:2aff0da5ebdb 3074 motor[TIRE_BR].pwm = 45;
yabahiro 38:40e7fdf3c694 3075 motor[TIRE_BR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 3076 motor[TIRE_BL].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 3077 motor[TIRE_BL].dir = BRAKE;
kishibekairohan 44:2aff0da5ebdb 3078 if(g[2]==0) {
yabahiro 38:40e7fdf3c694 3079 cross=0;
yabahiro 33:dd598bb23ad1 3080 countss=0;
yabahiro 33:dd598bb23ad1 3081 mode=40;
yabahiro 33:dd598bb23ad1 3082 }
yabahiro 46:68296caae1af 3083 } else if(mode==40) {
yabahiro 33:dd598bb23ad1 3084 switch(g[3]) {
yabahiro 33:dd598bb23ad1 3085 case 98:
yabahiro 46:68296caae1af 3086 motor[TIRE_FR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3087 motor[TIRE_FR].dir = BACK;
yabahiro 46:68296caae1af 3088 motor[TIRE_FL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3089 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3090 motor[TIRE_BR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3091 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 3092 motor[TIRE_BL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3093 motor[TIRE_BL].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 3094 if(countss>30000) {
yabahiro 33:dd598bb23ad1 3095 cross++;
yabahiro 33:dd598bb23ad1 3096 countss=0;
yabahiro 33:dd598bb23ad1 3097 }
yabahiro 33:dd598bb23ad1 3098 mtc2=true;
yabahiro 33:dd598bb23ad1 3099 break;
yabahiro 33:dd598bb23ad1 3100 case 0:
yabahiro 46:68296caae1af 3101 motor[TIRE_FR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3102 motor[TIRE_FR].dir = BACK;
yabahiro 46:68296caae1af 3103 motor[TIRE_FL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3104 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3105 motor[TIRE_BR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3106 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 3107 motor[TIRE_BL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3108 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3109 mtc2=true;
yabahiro 33:dd598bb23ad1 3110 break;
yabahiro 33:dd598bb23ad1 3111 case 255:
yabahiro 46:68296caae1af 3112 motor[TIRE_FR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3113 motor[TIRE_FR].dir = BACK;
yabahiro 46:68296caae1af 3114 motor[TIRE_FL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3115 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3116 motor[TIRE_BR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3117 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 3118 motor[TIRE_BL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3119 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3120 mtc2=true;
yabahiro 33:dd598bb23ad1 3121 break;
yabahiro 33:dd598bb23ad1 3122 case 253:
yabahiro 33:dd598bb23ad1 3123 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3124 motor[TIRE_FR].dir = FREE;
yabahiro 46:68296caae1af 3125 motor[TIRE_FL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3126 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3127 motor[TIRE_BR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3128 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3129 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3130 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3131 mtc2=true;
yabahiro 33:dd598bb23ad1 3132 break;
yabahiro 33:dd598bb23ad1 3133 case 254:
yabahiro 33:dd598bb23ad1 3134 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3135 motor[TIRE_FR].dir = FREE;
yabahiro 46:68296caae1af 3136 motor[TIRE_FL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3137 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3138 motor[TIRE_BR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3139 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3140 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3141 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3142 mtc2=true;
yabahiro 33:dd598bb23ad1 3143 break;
yabahiro 33:dd598bb23ad1 3144 case 1:
yabahiro 46:68296caae1af 3145 motor[TIRE_FR].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3146 motor[TIRE_FR].dir = BACK;
yabahiro 46:68296caae1af 3147 motor[TIRE_FL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3148 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3149 motor[TIRE_BR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3150 motor[TIRE_BR].dir = FOR;
yabahiro 46:68296caae1af 3151 motor[TIRE_BL].pwm = fast+15;
yabahiro 33:dd598bb23ad1 3152 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3153 mtc2=true;
yabahiro 33:dd598bb23ad1 3154 break;
yabahiro 33:dd598bb23ad1 3155 case 3:
yabahiro 46:68296caae1af 3156 motor[TIRE_FR].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3157 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3158 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3159 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3160 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3161 motor[TIRE_BR].dir = FREE;
yabahiro 46:68296caae1af 3162 motor[TIRE_BL].pwm = slow+15;
yabahiro 33:dd598bb23ad1 3163 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3164 mtc2=true;
yabahiro 33:dd598bb23ad1 3165 break;
yabahiro 33:dd598bb23ad1 3166 case 2:
yabahiro 46:68296caae1af 3167 motor[TIRE_FR].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3168 motor[TIRE_FR].dir = BACK;
yabahiro 33:dd598bb23ad1 3169 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3170 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3171 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3172 motor[TIRE_BR].dir = FREE;
yabahiro 46:68296caae1af 3173 motor[TIRE_BL].pwm = normal+15;
yabahiro 33:dd598bb23ad1 3174 motor[TIRE_BL].dir = FOR;
yabahiro 33:dd598bb23ad1 3175 mtc2=true;
yabahiro 33:dd598bb23ad1 3176 break;
yabahiro 33:dd598bb23ad1 3177 }
yabahiro 33:dd598bb23ad1 3178 if(g[2]!=98&&mtc2==true) {
yabahiro 33:dd598bb23ad1 3179 switch(g[2]) {
yabahiro 33:dd598bb23ad1 3180 case 0:
yabahiro 33:dd598bb23ad1 3181 mtc2=false;
yabahiro 33:dd598bb23ad1 3182 break;
yabahiro 33:dd598bb23ad1 3183 case 255:
kishibekairohan 44:2aff0da5ebdb 3184 motor[TIRE_FR].pwm += 3;
yabahiro 33:dd598bb23ad1 3185 mtc2=false;
yabahiro 33:dd598bb23ad1 3186 break;
yabahiro 33:dd598bb23ad1 3187 case 253:
kishibekairohan 44:2aff0da5ebdb 3188 motor[TIRE_FR].pwm += 6;
yabahiro 33:dd598bb23ad1 3189 mtc2=false;
yabahiro 33:dd598bb23ad1 3190 break;
yabahiro 33:dd598bb23ad1 3191 case 254:
kishibekairohan 44:2aff0da5ebdb 3192 motor[TIRE_FR].pwm += 9;
kishibekairohan 44:2aff0da5ebdb 3193 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3194 mtc2=false;
yabahiro 33:dd598bb23ad1 3195 break;
yabahiro 33:dd598bb23ad1 3196 case 1:
kishibekairohan 44:2aff0da5ebdb 3197 motor[TIRE_BR].pwm += 3;
yabahiro 33:dd598bb23ad1 3198 mtc2=false;
yabahiro 33:dd598bb23ad1 3199 break;
yabahiro 33:dd598bb23ad1 3200 case 3:
kishibekairohan 44:2aff0da5ebdb 3201 motor[TIRE_BR].pwm += 6;
yabahiro 33:dd598bb23ad1 3202 mtc2=false;
yabahiro 33:dd598bb23ad1 3203 break;
yabahiro 33:dd598bb23ad1 3204 case 2:
kishibekairohan 44:2aff0da5ebdb 3205 motor[TIRE_BR].pwm += 9;
kishibekairohan 44:2aff0da5ebdb 3206 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3207 mtc2=false;
yabahiro 33:dd598bb23ad1 3208 break;
yabahiro 33:dd598bb23ad1 3209 }
yabahiro 33:dd598bb23ad1 3210 }
yabahiro 46:68296caae1af 3211
kishibekairohan 42:980af34f6fe3 3212 if(YELLOW) {
kishibekairohan 42:980af34f6fe3 3213 if(cross==1) {
kishibekairohan 42:980af34f6fe3 3214 mode=41;
kishibekairohan 42:980af34f6fe3 3215 countss=0;
kishibekairohan 42:980af34f6fe3 3216 cross=0;
kishibekairohan 42:980af34f6fe3 3217 }
yabahiro 46:68296caae1af 3218 } else {
kishibekairohan 42:980af34f6fe3 3219 if(cross==3) {
kishibekairohan 42:980af34f6fe3 3220 mode=41;
kishibekairohan 42:980af34f6fe3 3221 countss=0;
kishibekairohan 42:980af34f6fe3 3222 cross=0;
kishibekairohan 42:980af34f6fe3 3223 }
kishibekairohan 42:980af34f6fe3 3224 }
yabahiro 46:68296caae1af 3225 if(LIF||LIB) {
yabahiro 46:68296caae1af 3226 mode=42;
yabahiro 46:68296caae1af 3227 }
yabahiro 46:68296caae1af 3228
yabahiro 46:68296caae1af 3229 } else if(mode==41) {
yabahiro 33:dd598bb23ad1 3230 if(LIF||LIB) {
yabahiro 33:dd598bb23ad1 3231 mode=42;
yabahiro 33:dd598bb23ad1 3232 }
kishibekairohan 44:2aff0da5ebdb 3233 motor[TIRE_FR].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 3234 motor[TIRE_FR].dir = BRAKE;
kishibekairohan 42:980af34f6fe3 3235 motor[TIRE_FL].pwm = 40;
yabahiro 33:dd598bb23ad1 3236 motor[TIRE_FL].dir = BACK;
kishibekairohan 42:980af34f6fe3 3237 motor[TIRE_BR].pwm = 40;
yabahiro 33:dd598bb23ad1 3238 motor[TIRE_BR].dir = FOR;
kishibekairohan 44:2aff0da5ebdb 3239 motor[TIRE_BL].pwm = 255;
kishibekairohan 44:2aff0da5ebdb 3240 motor[TIRE_BL].dir = BRAKE;
yabahiro 33:dd598bb23ad1 3241 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 3242 countss=0;
yabahiro 33:dd598bb23ad1 3243 mode=70;
kishibekairohan 42:980af34f6fe3 3244 normal=80;
kishibekairohan 42:980af34f6fe3 3245 fast=100;
kishibekairohan 42:980af34f6fe3 3246 slow=60;
yabahiro 33:dd598bb23ad1 3247 }
yabahiro 46:68296caae1af 3248 } else if(mode==42) {
kishibekairohan 42:980af34f6fe3 3249 motor[TIRE_FR].pwm = 40;
yabahiro 33:dd598bb23ad1 3250 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3251 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3252 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3253 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3254 motor[TIRE_BR].dir = FREE;
kishibekairohan 42:980af34f6fe3 3255 motor[TIRE_BL].pwm = 40;
yabahiro 33:dd598bb23ad1 3256 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3257 if(g[1]==0) {
yabahiro 33:dd598bb23ad1 3258 countss=0;
yabahiro 33:dd598bb23ad1 3259 mode=70;
yabahiro 33:dd598bb23ad1 3260 }
yabahiro 46:68296caae1af 3261 } else if(mode==70) {
yabahiro 33:dd598bb23ad1 3262 switch(g[1]) {
yabahiro 33:dd598bb23ad1 3263 case 99:
yabahiro 33:dd598bb23ad1 3264 if(countss>=100000) {
yabahiro 33:dd598bb23ad1 3265 mode=100;
yabahiro 33:dd598bb23ad1 3266 }
yabahiro 33:dd598bb23ad1 3267 break;
yabahiro 33:dd598bb23ad1 3268 case 98:
yabahiro 33:dd598bb23ad1 3269 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3270 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3271 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3272 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3273 motor[TIRE_BR].pwm = normal+5;
yabahiro 33:dd598bb23ad1 3274 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3275 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3276 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3277 break;
yabahiro 33:dd598bb23ad1 3278 case 0:
kishibekairohan 42:980af34f6fe3 3279 motor[TIRE_FR].pwm = 100;
yabahiro 33:dd598bb23ad1 3280 motor[TIRE_FR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3281 motor[TIRE_FL].pwm = 100;
yabahiro 33:dd598bb23ad1 3282 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3283 motor[TIRE_BR].pwm = 105;
yabahiro 33:dd598bb23ad1 3284 motor[TIRE_BR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3285 motor[TIRE_BL].pwm = 100;
yabahiro 33:dd598bb23ad1 3286 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3287 mtc=true;
yabahiro 33:dd598bb23ad1 3288 break;
yabahiro 33:dd598bb23ad1 3289 case 255:
yabahiro 33:dd598bb23ad1 3290 motor[TIRE_FR].pwm = fast;
yabahiro 33:dd598bb23ad1 3291 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3292 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3293 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3294 motor[TIRE_BR].pwm = slow+5;
yabahiro 33:dd598bb23ad1 3295 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3296 motor[TIRE_BL].pwm = fast;
yabahiro 33:dd598bb23ad1 3297 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3298 mtc=true;
yabahiro 33:dd598bb23ad1 3299 break;
yabahiro 33:dd598bb23ad1 3300 case 253:
yabahiro 33:dd598bb23ad1 3301 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3302 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3303 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3304 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3305 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3306 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3307 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3308 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3309 mtc=true;
yabahiro 33:dd598bb23ad1 3310 break;
yabahiro 33:dd598bb23ad1 3311 case 254:
yabahiro 33:dd598bb23ad1 3312 motor[TIRE_FR].pwm = normal;
yabahiro 33:dd598bb23ad1 3313 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3314 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3315 motor[TIRE_FL].dir = FREE;
yabahiro 33:dd598bb23ad1 3316 motor[TIRE_BR].pwm = 0;
yabahiro 33:dd598bb23ad1 3317 motor[TIRE_BR].dir = FREE;
yabahiro 33:dd598bb23ad1 3318 motor[TIRE_BL].pwm = normal;
yabahiro 33:dd598bb23ad1 3319 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3320 mtc=true;
yabahiro 33:dd598bb23ad1 3321 break;
yabahiro 33:dd598bb23ad1 3322 case 1:
yabahiro 33:dd598bb23ad1 3323 motor[TIRE_FR].pwm = slow;
yabahiro 33:dd598bb23ad1 3324 motor[TIRE_FR].dir = FOR;
yabahiro 33:dd598bb23ad1 3325 motor[TIRE_FL].pwm = fast;
yabahiro 33:dd598bb23ad1 3326 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3327 motor[TIRE_BR].pwm = fast+5;
yabahiro 33:dd598bb23ad1 3328 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3329 motor[TIRE_BL].pwm = slow;
yabahiro 33:dd598bb23ad1 3330 motor[TIRE_BL].dir = BACK;
yabahiro 33:dd598bb23ad1 3331 mtc=true;
yabahiro 33:dd598bb23ad1 3332 break;
yabahiro 33:dd598bb23ad1 3333 case 3:
yabahiro 33:dd598bb23ad1 3334 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3335 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3336 motor[TIRE_FL].pwm = slow;
yabahiro 33:dd598bb23ad1 3337 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3338 motor[TIRE_BR].pwm = slow+5;
yabahiro 33:dd598bb23ad1 3339 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3340 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3341 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3342 mtc=true;
yabahiro 33:dd598bb23ad1 3343 break;
yabahiro 33:dd598bb23ad1 3344 case 2:
yabahiro 33:dd598bb23ad1 3345 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3346 motor[TIRE_FR].dir = FREE;
yabahiro 33:dd598bb23ad1 3347 motor[TIRE_FL].pwm = normal;
yabahiro 33:dd598bb23ad1 3348 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3349 motor[TIRE_BR].pwm = normal+5;
yabahiro 33:dd598bb23ad1 3350 motor[TIRE_BR].dir = FOR;
yabahiro 33:dd598bb23ad1 3351 motor[TIRE_BL].pwm = 0;
yabahiro 33:dd598bb23ad1 3352 motor[TIRE_BL].dir = FREE;
yabahiro 33:dd598bb23ad1 3353 mtc=true;
yabahiro 33:dd598bb23ad1 3354 break;
yabahiro 33:dd598bb23ad1 3355 }
yabahiro 33:dd598bb23ad1 3356 if(g[1]!=98&&mtc==true) {
yabahiro 33:dd598bb23ad1 3357 switch(g[0]) {
yabahiro 33:dd598bb23ad1 3358 case 0:
yabahiro 33:dd598bb23ad1 3359 mtc=false;
yabahiro 33:dd598bb23ad1 3360 break;
yabahiro 33:dd598bb23ad1 3361 case 255:
kishibekairohan 44:2aff0da5ebdb 3362 motor[TIRE_FL].pwm += 3;
yabahiro 33:dd598bb23ad1 3363 mtc=false;
yabahiro 33:dd598bb23ad1 3364 break;
yabahiro 33:dd598bb23ad1 3365 case 253:
kishibekairohan 44:2aff0da5ebdb 3366 motor[TIRE_FL].pwm += 6;
yabahiro 33:dd598bb23ad1 3367 mtc=false;
yabahiro 33:dd598bb23ad1 3368 break;
yabahiro 33:dd598bb23ad1 3369 case 254:
kishibekairohan 44:2aff0da5ebdb 3370 motor[TIRE_FL].pwm += 9;
yabahiro 33:dd598bb23ad1 3371 motor[TIRE_FR].pwm = 0;
yabahiro 33:dd598bb23ad1 3372 mtc=false;
yabahiro 33:dd598bb23ad1 3373 break;
yabahiro 33:dd598bb23ad1 3374 case 1:
kishibekairohan 44:2aff0da5ebdb 3375 motor[TIRE_FR].pwm += 3;
yabahiro 33:dd598bb23ad1 3376 mtc=false;
yabahiro 33:dd598bb23ad1 3377 break;
yabahiro 33:dd598bb23ad1 3378 case 3:
kishibekairohan 44:2aff0da5ebdb 3379 motor[TIRE_FR].pwm += 6;
yabahiro 33:dd598bb23ad1 3380 mtc=false;
yabahiro 33:dd598bb23ad1 3381 break;
yabahiro 33:dd598bb23ad1 3382 case 2:
kishibekairohan 44:2aff0da5ebdb 3383 motor[TIRE_FR].pwm += 9;
yabahiro 33:dd598bb23ad1 3384 motor[TIRE_FL].pwm = 0;
yabahiro 33:dd598bb23ad1 3385 mtc=false;
yabahiro 33:dd598bb23ad1 3386 break;
yabahiro 33:dd598bb23ad1 3387 }
yabahiro 33:dd598bb23ad1 3388 }
yabahiro 46:68296caae1af 3389 } else if(mode==100) {
kishibekairohan 42:980af34f6fe3 3390 motor[TIRE_FR].pwm = 50;
yabahiro 33:dd598bb23ad1 3391 motor[TIRE_FR].dir = FOR;
yabahiro 46:68296caae1af 3392 motor[TIRE_FL].pwm = 55;
yabahiro 33:dd598bb23ad1 3393 motor[TIRE_FL].dir = BACK;
yabahiro 46:68296caae1af 3394 motor[TIRE_BR].pwm = 60;
yabahiro 33:dd598bb23ad1 3395 motor[TIRE_BR].dir = FOR;
kishibekairohan 42:980af34f6fe3 3396 motor[TIRE_BL].pwm = 50;
yabahiro 33:dd598bb23ad1 3397 motor[TIRE_BL].dir = BACK;
yabahiro 46:68296caae1af 3398 }
yabahiro 46:68296caae1af 3399
kishibekairohan 13:b6e02d6261d7 3400 }
kishibekairohan 13:b6e02d6261d7 3401 #endif
kishibekairohan 13:b6e02d6261d7 3402
kishibekairohan 13:b6e02d6261d7 3403 #if USE_PROCESS_NUM>4
Ryosei 27:dd9f27fce7d1 3404 static void Process4()
M_souta 22:7d93f79a3686 3405 {
yabahiro 48:5562a99479e5 3406 //Oh So 決勝青ゾーン
yabahiro 48:5562a99479e5 3407 LED::LED::TapeledMode(2);
yabahiro 48:5562a99479e5 3408 countss++;
yabahiro 48:5562a99479e5 3409 if(mode==1) {//スタートゾーンから白線検知
yabahiro 48:5562a99479e5 3410 fast=40;
yabahiro 48:5562a99479e5 3411 normal=30;
yabahiro 48:5562a99479e5 3412 slow=20;
yabahiro 48:5562a99479e5 3413 motor[TIRE_FR].pwm = normal+20;
yabahiro 48:5562a99479e5 3414 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3415 motor[TIRE_FL].pwm = normal+20;
yabahiro 48:5562a99479e5 3416 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3417 motor[TIRE_BR].pwm = normal+20;
yabahiro 48:5562a99479e5 3418 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3419 motor[TIRE_BL].pwm = normal+20;
yabahiro 48:5562a99479e5 3420 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3421 if(g[2]==0&&countss>=100000) {
yabahiro 48:5562a99479e5 3422 countss=100000;
yabahiro 48:5562a99479e5 3423 cross=0;
yabahiro 48:5562a99479e5 3424 mode=3;
yabahiro 48:5562a99479e5 3425 }
yabahiro 48:5562a99479e5 3426 } else if(mode==3) { //横ライントレースから縦ライントレースへ
yabahiro 48:5562a99479e5 3427 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 3428 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3429 motor[TIRE_FL].pwm = 255;
yabahiro 48:5562a99479e5 3430 motor[TIRE_FL].dir = BRAKE;
yabahiro 48:5562a99479e5 3431 motor[TIRE_BR].pwm = 255;
yabahiro 48:5562a99479e5 3432 motor[TIRE_BR].dir = BRAKE;
yabahiro 48:5562a99479e5 3433 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 3434 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3435 if(g[1]==0) {
yabahiro 48:5562a99479e5 3436 mode=10;
yabahiro 48:5562a99479e5 3437 countss=100000;
yabahiro 48:5562a99479e5 3438 }
yabahiro 48:5562a99479e5 3439 } else if(mode==10) { //縦ライントレース
yabahiro 48:5562a99479e5 3440 switch(g[1]) {
yabahiro 48:5562a99479e5 3441 case 98:
yabahiro 48:5562a99479e5 3442 motor[TIRE_FR].pwm = normal+50;
yabahiro 48:5562a99479e5 3443 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3444 motor[TIRE_FL].pwm = normal+50;
yabahiro 48:5562a99479e5 3445 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3446 motor[TIRE_BR].pwm = normal+50;
yabahiro 48:5562a99479e5 3447 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3448 motor[TIRE_BL].pwm = normal+50;
yabahiro 48:5562a99479e5 3449 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3450 mtc=true;
yabahiro 48:5562a99479e5 3451 if(countss>80000) {
yabahiro 48:5562a99479e5 3452 cross++;
yabahiro 48:5562a99479e5 3453 countss=0;
yabahiro 48:5562a99479e5 3454 }
yabahiro 48:5562a99479e5 3455
yabahiro 48:5562a99479e5 3456 if(cross==2) {
yabahiro 48:5562a99479e5 3457 fast = 10;
yabahiro 48:5562a99479e5 3458 normal = 10;
yabahiro 48:5562a99479e5 3459 slow = 5;
yabahiro 48:5562a99479e5 3460 }
yabahiro 48:5562a99479e5 3461
yabahiro 48:5562a99479e5 3462 if(cross==3) {
yabahiro 48:5562a99479e5 3463 fast=40;
yabahiro 48:5562a99479e5 3464 normal=30;
yabahiro 48:5562a99479e5 3465 slow=20;
yabahiro 48:5562a99479e5 3466 mode=11;
yabahiro 48:5562a99479e5 3467 countss=0;
yabahiro 48:5562a99479e5 3468 cross=0;
yabahiro 48:5562a99479e5 3469 }
yabahiro 48:5562a99479e5 3470 break;
yabahiro 48:5562a99479e5 3471 case 0:
yabahiro 48:5562a99479e5 3472 motor[TIRE_FR].pwm = fast+50;
yabahiro 48:5562a99479e5 3473 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3474 motor[TIRE_FL].pwm = fast+50;
yabahiro 48:5562a99479e5 3475 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3476 motor[TIRE_BR].pwm = fast+50;
yabahiro 48:5562a99479e5 3477 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3478 motor[TIRE_BL].pwm = fast+50;
yabahiro 48:5562a99479e5 3479 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3480 mtc=true;
yabahiro 48:5562a99479e5 3481 break;
yabahiro 48:5562a99479e5 3482 case 255:
yabahiro 48:5562a99479e5 3483 motor[TIRE_FR].pwm = fast+50;
yabahiro 48:5562a99479e5 3484 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3485 motor[TIRE_FL].pwm = slow+50;
yabahiro 48:5562a99479e5 3486 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3487 motor[TIRE_BR].pwm = slow+50;
yabahiro 48:5562a99479e5 3488 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3489 motor[TIRE_BL].pwm = fast+50;
yabahiro 48:5562a99479e5 3490 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3491 mtc=true;
yabahiro 48:5562a99479e5 3492 break;
yabahiro 48:5562a99479e5 3493 case 253:
yabahiro 48:5562a99479e5 3494 motor[TIRE_FR].pwm = slow+50;
yabahiro 48:5562a99479e5 3495 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3496 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3497 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3498 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3499 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3500 motor[TIRE_BL].pwm = slow+50;
yabahiro 48:5562a99479e5 3501 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3502 mtc=true;
yabahiro 48:5562a99479e5 3503 break;
yabahiro 48:5562a99479e5 3504 case 254:
yabahiro 48:5562a99479e5 3505 motor[TIRE_FR].pwm = normal+50;
yabahiro 48:5562a99479e5 3506 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3507 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3508 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3509 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3510 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3511 motor[TIRE_BL].pwm = normal+50;
yabahiro 48:5562a99479e5 3512 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3513 mtc=true;
yabahiro 48:5562a99479e5 3514 break;
yabahiro 48:5562a99479e5 3515 case 1:
yabahiro 48:5562a99479e5 3516 motor[TIRE_FR].pwm = slow+50;
yabahiro 48:5562a99479e5 3517 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3518 motor[TIRE_FL].pwm = fast+50;
yabahiro 48:5562a99479e5 3519 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3520 motor[TIRE_BR].pwm = fast+50;
yabahiro 48:5562a99479e5 3521 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3522 motor[TIRE_BL].pwm = slow+50;
yabahiro 48:5562a99479e5 3523 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3524 mtc=true;
yabahiro 48:5562a99479e5 3525 break;
yabahiro 48:5562a99479e5 3526 case 3:
yabahiro 48:5562a99479e5 3527 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3528 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3529 motor[TIRE_FL].pwm = slow+50;
yabahiro 48:5562a99479e5 3530 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3531 motor[TIRE_BR].pwm = slow+50;
yabahiro 48:5562a99479e5 3532 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3533 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3534 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3535 mtc=true;
yabahiro 48:5562a99479e5 3536 break;
yabahiro 48:5562a99479e5 3537 case 2:
yabahiro 48:5562a99479e5 3538 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3539 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3540 motor[TIRE_FL].pwm = normal+50;
yabahiro 48:5562a99479e5 3541 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3542 motor[TIRE_BR].pwm = normal+50;
yabahiro 48:5562a99479e5 3543 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3544 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3545 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3546 mtc=true;
yabahiro 48:5562a99479e5 3547 break;
yabahiro 48:5562a99479e5 3548 }
yabahiro 48:5562a99479e5 3549 if(g[1]!=98&&mtc==true) {
yabahiro 48:5562a99479e5 3550 switch(g[0]) {
yabahiro 48:5562a99479e5 3551 case 0:
yabahiro 48:5562a99479e5 3552 mtc=false;
yabahiro 48:5562a99479e5 3553 break;
yabahiro 48:5562a99479e5 3554 case 255:
yabahiro 48:5562a99479e5 3555 motor[TIRE_FL].pwm += 3;
yabahiro 48:5562a99479e5 3556 mtc=false;
yabahiro 48:5562a99479e5 3557 break;
yabahiro 48:5562a99479e5 3558 case 253:
yabahiro 48:5562a99479e5 3559 motor[TIRE_FL].pwm += 6;
yabahiro 48:5562a99479e5 3560 mtc=false;
yabahiro 48:5562a99479e5 3561 break;
yabahiro 48:5562a99479e5 3562 case 254:
yabahiro 48:5562a99479e5 3563 motor[TIRE_FL].pwm += 9;
yabahiro 48:5562a99479e5 3564 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3565 mtc=false;
yabahiro 48:5562a99479e5 3566 break;
yabahiro 48:5562a99479e5 3567 case 1:
yabahiro 48:5562a99479e5 3568 motor[TIRE_FR].pwm += 3;
yabahiro 48:5562a99479e5 3569 mtc=false;
yabahiro 48:5562a99479e5 3570 break;
yabahiro 48:5562a99479e5 3571 case 3:
yabahiro 48:5562a99479e5 3572 motor[TIRE_FR].pwm += 6;
yabahiro 48:5562a99479e5 3573 mtc=false;
yabahiro 48:5562a99479e5 3574 break;
yabahiro 48:5562a99479e5 3575 case 2:
yabahiro 48:5562a99479e5 3576 motor[TIRE_FR].pwm += 9;
yabahiro 48:5562a99479e5 3577 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3578 mtc=false;
yabahiro 48:5562a99479e5 3579 break;
yabahiro 48:5562a99479e5 3580 }
yabahiro 48:5562a99479e5 3581 }
yabahiro 48:5562a99479e5 3582 } else if(mode==11) {
yabahiro 48:5562a99479e5 3583 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 3584 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3585 motor[TIRE_FL].pwm = 25;
yabahiro 48:5562a99479e5 3586 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3587 motor[TIRE_BR].pwm = 25;
yabahiro 48:5562a99479e5 3588 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3589 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 3590 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3591 if(g[2]==0 || g[2]==255 || g[2]==254 || g[2]==253) {
yabahiro 48:5562a99479e5 3592 countss=0;
yabahiro 48:5562a99479e5 3593 cross=0;
yabahiro 48:5562a99479e5 3594 mode=20;
yabahiro 48:5562a99479e5 3595 }
yabahiro 48:5562a99479e5 3596 } else if(mode==20) {
yabahiro 48:5562a99479e5 3597 solenoid.solenoid4= SOLENOID_ON;
yabahiro 48:5562a99479e5 3598 switch(g[2]) {
yabahiro 48:5562a99479e5 3599 case 98:
yabahiro 48:5562a99479e5 3600 motor[TIRE_FR].pwm = normal+20;
yabahiro 48:5562a99479e5 3601 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3602 motor[TIRE_FL].pwm = normal+20;
yabahiro 48:5562a99479e5 3603 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3604 motor[TIRE_BR].pwm = normal+20;
yabahiro 48:5562a99479e5 3605 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3606 motor[TIRE_BL].pwm = normal+20;
yabahiro 48:5562a99479e5 3607 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3608 if(countss>30000) {
yabahiro 48:5562a99479e5 3609 cross++;
yabahiro 48:5562a99479e5 3610 countss=0;
yabahiro 48:5562a99479e5 3611 }
yabahiro 48:5562a99479e5 3612 mtc2=true;
yabahiro 48:5562a99479e5 3613
yabahiro 48:5562a99479e5 3614 if(YELLOW) {
yabahiro 48:5562a99479e5 3615 if(cross==1) {
yabahiro 48:5562a99479e5 3616 fast=20;
yabahiro 48:5562a99479e5 3617 normal=15;
yabahiro 48:5562a99479e5 3618 slow=15;
yabahiro 48:5562a99479e5 3619 } else if(cross==2) {
yabahiro 48:5562a99479e5 3620 mode=21;
yabahiro 48:5562a99479e5 3621 countss=0;
yabahiro 48:5562a99479e5 3622 cross=0;
yabahiro 48:5562a99479e5 3623 }
yabahiro 48:5562a99479e5 3624 } else {
yabahiro 48:5562a99479e5 3625 if(cross==3) {
yabahiro 48:5562a99479e5 3626 mode=21;
yabahiro 48:5562a99479e5 3627 countss=0;
yabahiro 48:5562a99479e5 3628 cross=0;
yabahiro 48:5562a99479e5 3629 }
yabahiro 48:5562a99479e5 3630 }
yabahiro 48:5562a99479e5 3631 break;
yabahiro 48:5562a99479e5 3632 case 0:
yabahiro 48:5562a99479e5 3633 motor[TIRE_FR].pwm = fast+20;
yabahiro 48:5562a99479e5 3634 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3635 motor[TIRE_FL].pwm = fast+20;
yabahiro 48:5562a99479e5 3636 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3637 motor[TIRE_BR].pwm = fast+20;
yabahiro 48:5562a99479e5 3638 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3639 motor[TIRE_BL].pwm = fast+20;
yabahiro 48:5562a99479e5 3640 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3641 mtc2=true;
yabahiro 48:5562a99479e5 3642 break;
yabahiro 48:5562a99479e5 3643 case 255:
yabahiro 48:5562a99479e5 3644 motor[TIRE_FR].pwm = normal+20;
yabahiro 48:5562a99479e5 3645 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3646 motor[TIRE_FL].pwm = fast+20;
yabahiro 48:5562a99479e5 3647 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3648 motor[TIRE_BR].pwm = fast+20;
yabahiro 48:5562a99479e5 3649 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3650 motor[TIRE_BL].pwm = normal+20;
yabahiro 48:5562a99479e5 3651 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3652 mtc2=true;
yabahiro 48:5562a99479e5 3653 break;
yabahiro 48:5562a99479e5 3654 case 253:
yabahiro 48:5562a99479e5 3655 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3656 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3657 motor[TIRE_FL].pwm = slow+20;
yabahiro 48:5562a99479e5 3658 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3659 motor[TIRE_BR].pwm = slow+20;
yabahiro 48:5562a99479e5 3660 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3661 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3662 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3663 mtc2=true;
yabahiro 48:5562a99479e5 3664 break;
yabahiro 48:5562a99479e5 3665 case 254:
yabahiro 48:5562a99479e5 3666 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3667 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3668 motor[TIRE_FL].pwm = normal+20;
yabahiro 48:5562a99479e5 3669 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3670 motor[TIRE_BR].pwm = normal+20;
yabahiro 48:5562a99479e5 3671 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3672 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3673 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3674 mtc2=true;
yabahiro 48:5562a99479e5 3675 break;
yabahiro 48:5562a99479e5 3676 case 1:
yabahiro 48:5562a99479e5 3677 motor[TIRE_FR].pwm = fast+20;
yabahiro 48:5562a99479e5 3678 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3679 motor[TIRE_FL].pwm = slow+20;
yabahiro 48:5562a99479e5 3680 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3681 motor[TIRE_BR].pwm = slow+20;
yabahiro 48:5562a99479e5 3682 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3683 motor[TIRE_BL].pwm = fast+20;
yabahiro 48:5562a99479e5 3684 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3685 mtc2=true;
yabahiro 48:5562a99479e5 3686 break;
yabahiro 48:5562a99479e5 3687 case 3:
yabahiro 48:5562a99479e5 3688 motor[TIRE_FR].pwm = slow+20;
yabahiro 48:5562a99479e5 3689 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3690 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3691 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3692 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3693 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3694 motor[TIRE_BL].pwm = slow+20;
yabahiro 48:5562a99479e5 3695 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3696 mtc2=true;
yabahiro 48:5562a99479e5 3697 break;
yabahiro 48:5562a99479e5 3698 case 2:
yabahiro 48:5562a99479e5 3699 motor[TIRE_FR].pwm = normal+20;
yabahiro 48:5562a99479e5 3700 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3701 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3702 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3703 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3704 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3705 motor[TIRE_BL].pwm = normal+20;
yabahiro 48:5562a99479e5 3706 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3707 mtc2=true;
yabahiro 48:5562a99479e5 3708 break;
yabahiro 48:5562a99479e5 3709 }
yabahiro 48:5562a99479e5 3710 if(g[2]!=98&&mtc2==true) {
yabahiro 48:5562a99479e5 3711 switch(g[3]) {
yabahiro 48:5562a99479e5 3712 case 0:
yabahiro 48:5562a99479e5 3713 mtc2=false;
yabahiro 48:5562a99479e5 3714 break;
yabahiro 48:5562a99479e5 3715 case 255:
yabahiro 48:5562a99479e5 3716 motor[TIRE_BL].pwm += 5;
yabahiro 48:5562a99479e5 3717 mtc2=false;
yabahiro 48:5562a99479e5 3718 break;
yabahiro 48:5562a99479e5 3719 case 253:
yabahiro 48:5562a99479e5 3720 motor[TIRE_BL].pwm += 10;
yabahiro 48:5562a99479e5 3721 mtc2=false;
yabahiro 48:5562a99479e5 3722 break;
yabahiro 48:5562a99479e5 3723 case 254:
yabahiro 48:5562a99479e5 3724 motor[TIRE_BL].pwm += 15;
yabahiro 48:5562a99479e5 3725 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3726 mtc2=false;
yabahiro 48:5562a99479e5 3727 break;
yabahiro 48:5562a99479e5 3728 case 1:
yabahiro 48:5562a99479e5 3729 motor[TIRE_FL].pwm += 5;
yabahiro 48:5562a99479e5 3730 mtc2=false;
yabahiro 48:5562a99479e5 3731 break;
yabahiro 48:5562a99479e5 3732 case 3:
yabahiro 48:5562a99479e5 3733 motor[TIRE_FL].pwm += 10;
yabahiro 48:5562a99479e5 3734 mtc2=false;
yabahiro 48:5562a99479e5 3735 break;
yabahiro 48:5562a99479e5 3736 case 2:
yabahiro 48:5562a99479e5 3737 motor[TIRE_FL].pwm += 15;
yabahiro 48:5562a99479e5 3738 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3739 mtc2=false;
yabahiro 48:5562a99479e5 3740 break;
yabahiro 48:5562a99479e5 3741 }
yabahiro 48:5562a99479e5 3742 }
yabahiro 48:5562a99479e5 3743 }
yabahiro 48:5562a99479e5 3744 if(YELLOW) {
yabahiro 48:5562a99479e5 3745 if(mode==21) {
yabahiro 48:5562a99479e5 3746 motor[TIRE_FR].pwm = 20;
yabahiro 48:5562a99479e5 3747 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3748 motor[TIRE_FL].pwm = 20;
yabahiro 48:5562a99479e5 3749 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3750 motor[TIRE_BR].pwm = 20;
yabahiro 48:5562a99479e5 3751 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3752 motor[TIRE_BL].pwm = 20;
yabahiro 48:5562a99479e5 3753 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3754 if(g[3]==98&&countss>=10000) {
yabahiro 48:5562a99479e5 3755 mode=22;
yabahiro 48:5562a99479e5 3756 countss=0;
yabahiro 48:5562a99479e5 3757 fast=60;
yabahiro 48:5562a99479e5 3758 normal=40;
yabahiro 48:5562a99479e5 3759 slow=20;
yabahiro 48:5562a99479e5 3760 }
yabahiro 48:5562a99479e5 3761 } else if(mode==22) {
yabahiro 48:5562a99479e5 3762 if(g[4]==3||g[4]==2) {
yabahiro 48:5562a99479e5 3763 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 3764 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3765 motor[TIRE_FL].pwm = 30;
yabahiro 48:5562a99479e5 3766 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3767 motor[TIRE_BR].pwm = 30;
yabahiro 48:5562a99479e5 3768 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3769 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 3770 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3771 }
yabahiro 48:5562a99479e5 3772 if(g[4]==253||g[4]==254) {
yabahiro 48:5562a99479e5 3773 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 3774 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3775 motor[TIRE_FL].pwm = 30;
yabahiro 48:5562a99479e5 3776 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3777 motor[TIRE_BR].pwm = 30;
yabahiro 48:5562a99479e5 3778 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3779 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 3780 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3781 }
yabahiro 48:5562a99479e5 3782 switch(g[2]) {
yabahiro 48:5562a99479e5 3783 case 0:
yabahiro 48:5562a99479e5 3784 motor[TIRE_FR].pwm = 20;
yabahiro 48:5562a99479e5 3785 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3786 motor[TIRE_BR].pwm = 20;
yabahiro 48:5562a99479e5 3787 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3788 break;
yabahiro 48:5562a99479e5 3789 case 255:
yabahiro 48:5562a99479e5 3790 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 3791 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3792 motor[TIRE_BR].pwm = 20;
yabahiro 48:5562a99479e5 3793 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3794 break;
yabahiro 48:5562a99479e5 3795 case 253:
yabahiro 48:5562a99479e5 3796 motor[TIRE_FR].pwm = 40;
yabahiro 48:5562a99479e5 3797 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3798 motor[TIRE_BR].pwm = 20;
yabahiro 48:5562a99479e5 3799 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3800 break;
yabahiro 48:5562a99479e5 3801 case 254:
yabahiro 48:5562a99479e5 3802 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 3803 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3804 motor[TIRE_BR].pwm = 30;
yabahiro 48:5562a99479e5 3805 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3806 break;
yabahiro 48:5562a99479e5 3807 case 1:
yabahiro 48:5562a99479e5 3808 motor[TIRE_FR].pwm = 20;
yabahiro 48:5562a99479e5 3809 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3810 motor[TIRE_BR].pwm = 30;
yabahiro 48:5562a99479e5 3811 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3812 break;
yabahiro 48:5562a99479e5 3813 case 3:
yabahiro 48:5562a99479e5 3814 motor[TIRE_FR].pwm = 20;
yabahiro 48:5562a99479e5 3815 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3816 motor[TIRE_BR].pwm = 40;
yabahiro 48:5562a99479e5 3817 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3818 break;
yabahiro 48:5562a99479e5 3819 case 2:
yabahiro 48:5562a99479e5 3820 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 3821 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 3822 motor[TIRE_BR].pwm = 30;
yabahiro 48:5562a99479e5 3823 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 3824 break;
yabahiro 48:5562a99479e5 3825 }
yabahiro 48:5562a99479e5 3826 switch(g[3]) {
yabahiro 48:5562a99479e5 3827 case 0:
yabahiro 48:5562a99479e5 3828 motor[TIRE_FL].pwm = 20;
yabahiro 48:5562a99479e5 3829 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3830 motor[TIRE_BL].pwm = 20;
yabahiro 48:5562a99479e5 3831 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3832 break;
yabahiro 48:5562a99479e5 3833 case 255:
yabahiro 48:5562a99479e5 3834 motor[TIRE_FL].pwm = 20;
yabahiro 48:5562a99479e5 3835 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3836 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 3837 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3838 case 253:
yabahiro 48:5562a99479e5 3839 motor[TIRE_FL].pwm = 20;
yabahiro 48:5562a99479e5 3840 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3841 motor[TIRE_BL].pwm = 40;
yabahiro 48:5562a99479e5 3842 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3843 break;
yabahiro 48:5562a99479e5 3844 case 254:
yabahiro 48:5562a99479e5 3845 motor[TIRE_FL].pwm = 30;
yabahiro 48:5562a99479e5 3846 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 3847 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 3848 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 3849 break;
yabahiro 48:5562a99479e5 3850 case 1:
yabahiro 48:5562a99479e5 3851 motor[TIRE_FL].pwm = 30;
yabahiro 48:5562a99479e5 3852 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3853 motor[TIRE_BL].pwm = 20;
yabahiro 48:5562a99479e5 3854 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3855 break;
yabahiro 48:5562a99479e5 3856 case 3:
yabahiro 48:5562a99479e5 3857 motor[TIRE_FL].pwm = 40;
yabahiro 48:5562a99479e5 3858 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3859 motor[TIRE_BL].pwm = 20;
yabahiro 48:5562a99479e5 3860 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3861 break;
yabahiro 48:5562a99479e5 3862 case 2:
yabahiro 48:5562a99479e5 3863 motor[TIRE_FL].pwm = 30;
yabahiro 48:5562a99479e5 3864 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3865 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 3866 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3867 break;
yabahiro 48:5562a99479e5 3868 }
yabahiro 48:5562a99479e5 3869 if(g[3]==0&&g[2]==0) {
yabahiro 48:5562a99479e5 3870 mode=23;
yabahiro 48:5562a99479e5 3871 countss=0;
yabahiro 48:5562a99479e5 3872 }
yabahiro 48:5562a99479e5 3873 } else if(mode==23) {
yabahiro 48:5562a99479e5 3874 switch(g[4]) {
yabahiro 48:5562a99479e5 3875 case 98:
yabahiro 48:5562a99479e5 3876 motor[TIRE_FR].pwm = fast-5;
yabahiro 48:5562a99479e5 3877 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3878 motor[TIRE_FL].pwm = fast-5;
yabahiro 48:5562a99479e5 3879 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3880 motor[TIRE_BR].pwm = fast-5;
yabahiro 48:5562a99479e5 3881 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3882 motor[TIRE_BL].pwm = fast-5;
yabahiro 48:5562a99479e5 3883 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3884 break;
yabahiro 48:5562a99479e5 3885 case 99:
yabahiro 48:5562a99479e5 3886 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3887 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3888 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3889 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3890 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3891 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3892 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3893 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3894 break;
yabahiro 48:5562a99479e5 3895 case 0:
yabahiro 48:5562a99479e5 3896 motor[TIRE_FR].pwm = fast-5;
yabahiro 48:5562a99479e5 3897 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3898 motor[TIRE_FL].pwm = fast-5;
yabahiro 48:5562a99479e5 3899 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3900 motor[TIRE_BR].pwm = fast-5;
yabahiro 48:5562a99479e5 3901 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3902 motor[TIRE_BL].pwm = fast-5;
yabahiro 48:5562a99479e5 3903 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3904 break;
yabahiro 48:5562a99479e5 3905 case 255:
yabahiro 48:5562a99479e5 3906 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3907 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3908 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3909 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3910 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3911 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3912 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3913 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3914 break;
yabahiro 48:5562a99479e5 3915 case 253:
yabahiro 48:5562a99479e5 3916 motor[TIRE_FR].pwm = fast-5;
yabahiro 48:5562a99479e5 3917 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3918 motor[TIRE_FL].pwm = slow-5;
yabahiro 48:5562a99479e5 3919 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3920 motor[TIRE_BR].pwm = slow-5;
yabahiro 48:5562a99479e5 3921 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3922 motor[TIRE_BL].pwm = fast-5;
yabahiro 48:5562a99479e5 3923 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3924 break;
yabahiro 48:5562a99479e5 3925 case 254:
yabahiro 48:5562a99479e5 3926 motor[TIRE_FR].pwm = fast-5;
yabahiro 48:5562a99479e5 3927 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3928 motor[TIRE_FL].pwm = normal-5;
yabahiro 48:5562a99479e5 3929 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3930 motor[TIRE_BR].pwm = normal-5;
yabahiro 48:5562a99479e5 3931 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3932 motor[TIRE_BL].pwm = fast-5;
yabahiro 48:5562a99479e5 3933 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3934 break;
yabahiro 48:5562a99479e5 3935 case 1:
yabahiro 48:5562a99479e5 3936 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 3937 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 3938 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 3939 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 3940 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 3941 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 3942 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 3943 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 3944 break;
yabahiro 48:5562a99479e5 3945 case 3:
yabahiro 48:5562a99479e5 3946 motor[TIRE_FR].pwm = slow-5;
yabahiro 48:5562a99479e5 3947 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3948 motor[TIRE_FL].pwm = fast-5;
yabahiro 48:5562a99479e5 3949 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3950 motor[TIRE_BR].pwm = fast-5;
yabahiro 48:5562a99479e5 3951 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3952 motor[TIRE_BL].pwm = slow-5;
yabahiro 48:5562a99479e5 3953 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3954 break;
yabahiro 48:5562a99479e5 3955 case 2:
yabahiro 48:5562a99479e5 3956 motor[TIRE_FR].pwm = normal-5;
yabahiro 48:5562a99479e5 3957 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3958 motor[TIRE_FL].pwm = fast-5;
yabahiro 48:5562a99479e5 3959 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 3960 motor[TIRE_BR].pwm = fast-5;
yabahiro 48:5562a99479e5 3961 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 3962 motor[TIRE_BL].pwm = normal-5;
yabahiro 48:5562a99479e5 3963 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3964 break;
yabahiro 48:5562a99479e5 3965 }
yabahiro 48:5562a99479e5 3966 if(g[2]==254&&countss>=100000) {
yabahiro 48:5562a99479e5 3967 mode=24;
yabahiro 48:5562a99479e5 3968 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 48:5562a99479e5 3969 countss=0;
yabahiro 48:5562a99479e5 3970 fast=60;
yabahiro 48:5562a99479e5 3971 normal=40;
yabahiro 48:5562a99479e5 3972 slow=20;
yabahiro 48:5562a99479e5 3973 }
yabahiro 48:5562a99479e5 3974 } else if(mode==24) {
yabahiro 48:5562a99479e5 3975 motor[TIRE_FR].pwm = 60;
yabahiro 48:5562a99479e5 3976 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 3977 motor[TIRE_FL].pwm = 60;
yabahiro 48:5562a99479e5 3978 motor[TIRE_FL].dir = BRAKE;
yabahiro 48:5562a99479e5 3979 motor[TIRE_BR].pwm = 60;
yabahiro 48:5562a99479e5 3980 motor[TIRE_BR].dir = BRAKE;
yabahiro 48:5562a99479e5 3981 motor[TIRE_BL].pwm = 60;
yabahiro 48:5562a99479e5 3982 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 3983 if(g[0]==0) {
yabahiro 48:5562a99479e5 3984 mode=25;
yabahiro 48:5562a99479e5 3985 }
yabahiro 48:5562a99479e5 3986 } else if(mode==25) {
yabahiro 48:5562a99479e5 3987 motor[TIRE_FR].pwm = 100;
yabahiro 48:5562a99479e5 3988 motor[TIRE_FR].dir = BRAKE;
yabahiro 48:5562a99479e5 3989 motor[TIRE_FL].pwm = 100;
yabahiro 48:5562a99479e5 3990 motor[TIRE_FL].dir = BRAKE;
yabahiro 48:5562a99479e5 3991 motor[TIRE_BR].pwm = 100;
yabahiro 48:5562a99479e5 3992 motor[TIRE_BR].dir = BRAKE;
yabahiro 48:5562a99479e5 3993 motor[TIRE_BL].pwm = 100;
yabahiro 48:5562a99479e5 3994 motor[TIRE_BL].dir = BRAKE;
yabahiro 48:5562a99479e5 3995 if(DOLS==true||UPLS==true) {
yabahiro 48:5562a99479e5 3996 motor[MOTOR_0].pwm = 200;
yabahiro 48:5562a99479e5 3997 motor[MOTOR_0].dir = BRAKE;
yabahiro 48:5562a99479e5 3998 mode=26;
yabahiro 48:5562a99479e5 3999 countss=0;
yabahiro 48:5562a99479e5 4000 } else {
yabahiro 48:5562a99479e5 4001 motor[MOTOR_0].pwm = 100;
yabahiro 48:5562a99479e5 4002 motor[MOTOR_0].dir = BACK;
yabahiro 48:5562a99479e5 4003 }
yabahiro 48:5562a99479e5 4004 } else if(mode==26) {
yabahiro 48:5562a99479e5 4005 if(g[0]==98&&countss>=40000) {
yabahiro 48:5562a99479e5 4006 mode=31;
yabahiro 48:5562a99479e5 4007 countss=0;
yabahiro 48:5562a99479e5 4008 }
yabahiro 48:5562a99479e5 4009 switch(g[0]) {
yabahiro 48:5562a99479e5 4010 case 98:
yabahiro 48:5562a99479e5 4011 fast=40;
yabahiro 48:5562a99479e5 4012 normal=30;
yabahiro 48:5562a99479e5 4013 slow=25;
yabahiro 48:5562a99479e5 4014 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4015 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4016 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4017 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4018 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4019 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4020 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4021 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4022 break;
yabahiro 48:5562a99479e5 4023 case 0:
yabahiro 48:5562a99479e5 4024 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4025 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4026 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4027 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4028 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4029 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4030 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4031 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4032 mtc=true;
yabahiro 48:5562a99479e5 4033 break;
yabahiro 48:5562a99479e5 4034 case 255:
yabahiro 48:5562a99479e5 4035 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4036 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4037 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4038 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4039 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4040 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4041 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4042 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4043 mtc=true;
yabahiro 48:5562a99479e5 4044 break;
yabahiro 48:5562a99479e5 4045 case 253:
yabahiro 48:5562a99479e5 4046 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4047 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4048 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4049 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4050 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4051 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4052 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4053 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4054 mtc=true;
yabahiro 48:5562a99479e5 4055 break;
yabahiro 48:5562a99479e5 4056 case 254:
yabahiro 48:5562a99479e5 4057 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4058 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4059 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4060 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4061 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4062 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4063 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4064 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4065 mtc=true;
yabahiro 48:5562a99479e5 4066 break;
yabahiro 48:5562a99479e5 4067 case 1:
yabahiro 48:5562a99479e5 4068 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4069 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4070 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4071 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4072 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4073 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4074 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4075 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4076 mtc=true;
yabahiro 48:5562a99479e5 4077 break;
yabahiro 48:5562a99479e5 4078 case 3:
yabahiro 48:5562a99479e5 4079 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4080 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4081 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4082 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4083 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4084 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4085 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4086 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4087 mtc=true;
yabahiro 48:5562a99479e5 4088 break;
yabahiro 48:5562a99479e5 4089 case 2:
yabahiro 48:5562a99479e5 4090 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4091 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4092 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4093 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4094 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4095 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4096 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4097 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4098 mtc=true;
yabahiro 48:5562a99479e5 4099 break;
yabahiro 48:5562a99479e5 4100 }
yabahiro 48:5562a99479e5 4101 if(g[1]!=98&&mtc==true) {
yabahiro 48:5562a99479e5 4102 switch(g[1]) {
yabahiro 48:5562a99479e5 4103 case 0:
yabahiro 48:5562a99479e5 4104 mtc=false;
yabahiro 48:5562a99479e5 4105 break;
yabahiro 48:5562a99479e5 4106 case 255:
yabahiro 48:5562a99479e5 4107 motor[TIRE_BR].pwm += 5;
yabahiro 48:5562a99479e5 4108 mtc=false;
yabahiro 48:5562a99479e5 4109 break;
yabahiro 48:5562a99479e5 4110 case 253:
yabahiro 48:5562a99479e5 4111 motor[TIRE_BR].pwm += 10;
yabahiro 48:5562a99479e5 4112 mtc=false;
yabahiro 48:5562a99479e5 4113 break;
yabahiro 48:5562a99479e5 4114 case 254:
yabahiro 48:5562a99479e5 4115 motor[TIRE_BR].pwm += 20;
yabahiro 48:5562a99479e5 4116 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4117 mtc=false;
yabahiro 48:5562a99479e5 4118 break;
yabahiro 48:5562a99479e5 4119 case 1:
yabahiro 48:5562a99479e5 4120 motor[TIRE_BL].pwm += 5;
yabahiro 48:5562a99479e5 4121 mtc=false;
yabahiro 48:5562a99479e5 4122 break;
yabahiro 48:5562a99479e5 4123 case 3:
yabahiro 48:5562a99479e5 4124 motor[TIRE_BL].pwm += 10;
yabahiro 48:5562a99479e5 4125 mtc=false;
yabahiro 48:5562a99479e5 4126 break;
yabahiro 48:5562a99479e5 4127 case 2:
yabahiro 48:5562a99479e5 4128 motor[TIRE_BL].pwm += 20;
yabahiro 48:5562a99479e5 4129 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4130 mtc=false;
yabahiro 48:5562a99479e5 4131 break;
yabahiro 48:5562a99479e5 4132 }
yabahiro 48:5562a99479e5 4133 }
yabahiro 48:5562a99479e5 4134 }
yabahiro 48:5562a99479e5 4135 } else {
yabahiro 48:5562a99479e5 4136 if(mode==21) {
yabahiro 48:5562a99479e5 4137 motor[TIRE_FR].pwm = 255;
yabahiro 48:5562a99479e5 4138 motor[TIRE_FR].dir = BRAKE;
yabahiro 48:5562a99479e5 4139 motor[TIRE_FL].pwm = 30;
yabahiro 48:5562a99479e5 4140 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4141 motor[TIRE_BR].pwm = 30;
yabahiro 48:5562a99479e5 4142 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4143 motor[TIRE_BL].pwm = 255;
yabahiro 48:5562a99479e5 4144 motor[TIRE_BL].dir = BRAKE;
yabahiro 48:5562a99479e5 4145 if(g[1]==0) {
yabahiro 48:5562a99479e5 4146 mode=22;
yabahiro 48:5562a99479e5 4147 fast=60;
yabahiro 48:5562a99479e5 4148 normal=40;
yabahiro 48:5562a99479e5 4149 slow=25;
yabahiro 48:5562a99479e5 4150 }
yabahiro 48:5562a99479e5 4151 } else if(mode==22) {
yabahiro 48:5562a99479e5 4152 if(g[0]==98) {
yabahiro 48:5562a99479e5 4153 slow=25;
yabahiro 48:5562a99479e5 4154 normal=30;
yabahiro 48:5562a99479e5 4155 fast=40;
yabahiro 48:5562a99479e5 4156 }
yabahiro 48:5562a99479e5 4157 if(g[3]==0) {
yabahiro 48:5562a99479e5 4158 slow=25;
yabahiro 48:5562a99479e5 4159 normal=40;
yabahiro 48:5562a99479e5 4160 fast=40;
yabahiro 48:5562a99479e5 4161 mode=23;
yabahiro 48:5562a99479e5 4162 }
yabahiro 48:5562a99479e5 4163 switch(g[0]) {
yabahiro 48:5562a99479e5 4164 case 98:
yabahiro 48:5562a99479e5 4165 solenoid.solenoid4 = SOLENOID_OFF;
yabahiro 48:5562a99479e5 4166 fast=40;
yabahiro 48:5562a99479e5 4167 normal=30;
yabahiro 48:5562a99479e5 4168 slow=25;
yabahiro 48:5562a99479e5 4169 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4170 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4171 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4172 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4173 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4174 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4175 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4176 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4177 break;
yabahiro 48:5562a99479e5 4178 case 0:
yabahiro 48:5562a99479e5 4179 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4180 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4181 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4182 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4183 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4184 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4185 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4186 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4187 mtc=true;
yabahiro 48:5562a99479e5 4188 break;
yabahiro 48:5562a99479e5 4189 case 255:
yabahiro 48:5562a99479e5 4190 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4191 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4192 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4193 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4194 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4195 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4196 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4197 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4198 mtc=true;
yabahiro 48:5562a99479e5 4199 break;
yabahiro 48:5562a99479e5 4200 case 253:
yabahiro 48:5562a99479e5 4201 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4202 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4203 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4204 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4205 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4206 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4207 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4208 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4209 mtc=true;
yabahiro 48:5562a99479e5 4210 break;
yabahiro 48:5562a99479e5 4211 case 254:
yabahiro 48:5562a99479e5 4212 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4213 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4214 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4215 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4216 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4217 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4218 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4219 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4220 mtc=true;
yabahiro 48:5562a99479e5 4221 break;
yabahiro 48:5562a99479e5 4222 case 1:
yabahiro 48:5562a99479e5 4223 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4224 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4225 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4226 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4227 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4228 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4229 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4230 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4231 mtc=true;
yabahiro 48:5562a99479e5 4232 break;
yabahiro 48:5562a99479e5 4233 case 3:
yabahiro 48:5562a99479e5 4234 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4235 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4236 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4237 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4238 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4239 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4240 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4241 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4242 mtc=true;
yabahiro 48:5562a99479e5 4243 break;
yabahiro 48:5562a99479e5 4244 case 2:
yabahiro 48:5562a99479e5 4245 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4246 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4247 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4248 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4249 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4250 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4251 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4252 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4253 mtc=true;
yabahiro 48:5562a99479e5 4254 break;
yabahiro 48:5562a99479e5 4255 }
yabahiro 48:5562a99479e5 4256 if(g[0]!=98&&mtc==true) {
yabahiro 48:5562a99479e5 4257 switch(g[0]) {
yabahiro 48:5562a99479e5 4258 case 0:
yabahiro 48:5562a99479e5 4259 mtc=false;
yabahiro 48:5562a99479e5 4260 break;
yabahiro 48:5562a99479e5 4261 case 255:
yabahiro 48:5562a99479e5 4262 motor[TIRE_BR].pwm += 5;
yabahiro 48:5562a99479e5 4263 mtc=false;
yabahiro 48:5562a99479e5 4264 break;
yabahiro 48:5562a99479e5 4265 case 253:
yabahiro 48:5562a99479e5 4266 motor[TIRE_BR].pwm += 10;
yabahiro 48:5562a99479e5 4267 mtc=false;
yabahiro 48:5562a99479e5 4268 break;
yabahiro 48:5562a99479e5 4269 case 254:
yabahiro 48:5562a99479e5 4270 motor[TIRE_BR].pwm += 20;
yabahiro 48:5562a99479e5 4271 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4272 mtc=false;
yabahiro 48:5562a99479e5 4273 break;
yabahiro 48:5562a99479e5 4274 case 1:
yabahiro 48:5562a99479e5 4275 motor[TIRE_BL].pwm += 5;
yabahiro 48:5562a99479e5 4276 mtc=false;
yabahiro 48:5562a99479e5 4277 break;
yabahiro 48:5562a99479e5 4278 case 3:
yabahiro 48:5562a99479e5 4279 motor[TIRE_BL].pwm += 10;
yabahiro 48:5562a99479e5 4280 mtc=false;
yabahiro 48:5562a99479e5 4281 break;
yabahiro 48:5562a99479e5 4282 case 2:
yabahiro 48:5562a99479e5 4283 motor[TIRE_BL].pwm += 20;
yabahiro 48:5562a99479e5 4284 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4285 mtc=false;
yabahiro 48:5562a99479e5 4286 break;
yabahiro 48:5562a99479e5 4287 }
yabahiro 48:5562a99479e5 4288 }
yabahiro 48:5562a99479e5 4289 } else if(mode==23) {
yabahiro 48:5562a99479e5 4290 if(UPLS==true||DOLS==true) {
yabahiro 48:5562a99479e5 4291 motor[MOTOR_0].pwm = 200;
yabahiro 48:5562a99479e5 4292 motor[MOTOR_0].dir = BRAKE;
yabahiro 48:5562a99479e5 4293 fast=60;
yabahiro 48:5562a99479e5 4294 normal=40;
yabahiro 48:5562a99479e5 4295 slow=20;
yabahiro 48:5562a99479e5 4296 countss=0;
yabahiro 48:5562a99479e5 4297 mode=24;
yabahiro 48:5562a99479e5 4298 } else {
yabahiro 48:5562a99479e5 4299 motor[MOTOR_0].pwm = 100;
yabahiro 48:5562a99479e5 4300 motor[MOTOR_0].dir = BACK;
yabahiro 48:5562a99479e5 4301 }
yabahiro 48:5562a99479e5 4302 motor[TIRE_FR].pwm = 100;
yabahiro 48:5562a99479e5 4303 motor[TIRE_FR].dir = BRAKE;
yabahiro 48:5562a99479e5 4304 motor[TIRE_FL].pwm = 100;
yabahiro 48:5562a99479e5 4305 motor[TIRE_FL].dir = BRAKE;
yabahiro 48:5562a99479e5 4306 motor[TIRE_BR].pwm = 100;
yabahiro 48:5562a99479e5 4307 motor[TIRE_BR].dir = BRAKE;
yabahiro 48:5562a99479e5 4308 motor[TIRE_BL].pwm = 100;
yabahiro 48:5562a99479e5 4309 motor[TIRE_BL].dir = BRAKE;
yabahiro 48:5562a99479e5 4310 } else if(mode==24) {
yabahiro 48:5562a99479e5 4311 if(g[0]==98&&countss>=40000) {
yabahiro 48:5562a99479e5 4312 mode=31;
yabahiro 48:5562a99479e5 4313 countss=0;
yabahiro 48:5562a99479e5 4314 }
yabahiro 48:5562a99479e5 4315 switch(g[0]) {
yabahiro 48:5562a99479e5 4316 case 98:
yabahiro 48:5562a99479e5 4317 fast=40;
yabahiro 48:5562a99479e5 4318 normal=30;
yabahiro 48:5562a99479e5 4319 slow=25;
yabahiro 48:5562a99479e5 4320 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4321 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4322 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4323 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4324 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4325 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4326 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4327 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4328 break;
yabahiro 48:5562a99479e5 4329 case 0:
yabahiro 48:5562a99479e5 4330 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4331 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4332 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4333 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4334 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4335 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4336 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4337 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4338 mtc=true;
yabahiro 48:5562a99479e5 4339 break;
yabahiro 48:5562a99479e5 4340 case 255:
yabahiro 48:5562a99479e5 4341 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4342 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4343 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4344 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4345 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4346 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4347 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4348 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4349 mtc=true;
yabahiro 48:5562a99479e5 4350 break;
yabahiro 48:5562a99479e5 4351 case 253:
yabahiro 48:5562a99479e5 4352 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4353 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4354 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4355 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4356 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4357 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4358 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4359 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4360 mtc=true;
yabahiro 48:5562a99479e5 4361 break;
yabahiro 48:5562a99479e5 4362 case 254:
yabahiro 48:5562a99479e5 4363 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4364 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4365 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4366 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4367 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4368 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4369 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4370 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4371 mtc=true;
yabahiro 48:5562a99479e5 4372 break;
yabahiro 48:5562a99479e5 4373 case 1:
yabahiro 48:5562a99479e5 4374 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4375 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4376 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4377 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4378 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4379 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4380 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4381 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4382 mtc=true;
yabahiro 48:5562a99479e5 4383 break;
yabahiro 48:5562a99479e5 4384 case 3:
yabahiro 48:5562a99479e5 4385 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4386 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4387 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4388 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4389 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4390 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4391 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4392 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4393 mtc=true;
yabahiro 48:5562a99479e5 4394 break;
yabahiro 48:5562a99479e5 4395 case 2:
yabahiro 48:5562a99479e5 4396 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4397 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4398 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4399 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4400 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4401 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4402 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4403 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4404 mtc=true;
yabahiro 48:5562a99479e5 4405 break;
yabahiro 48:5562a99479e5 4406 }
yabahiro 48:5562a99479e5 4407 if(g[1]!=98&&mtc==true) {
yabahiro 48:5562a99479e5 4408 switch(g[1]) {
yabahiro 48:5562a99479e5 4409 case 0:
yabahiro 48:5562a99479e5 4410 mtc=false;
yabahiro 48:5562a99479e5 4411 break;
yabahiro 48:5562a99479e5 4412 case 255:
yabahiro 48:5562a99479e5 4413 motor[TIRE_BR].pwm += 5;
yabahiro 48:5562a99479e5 4414 mtc=false;
yabahiro 48:5562a99479e5 4415 break;
yabahiro 48:5562a99479e5 4416 case 253:
yabahiro 48:5562a99479e5 4417 motor[TIRE_BR].pwm += 10;
yabahiro 48:5562a99479e5 4418 mtc=false;
yabahiro 48:5562a99479e5 4419 break;
yabahiro 48:5562a99479e5 4420 case 254:
yabahiro 48:5562a99479e5 4421 motor[TIRE_BR].pwm += 20;
yabahiro 48:5562a99479e5 4422 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4423 mtc=false;
yabahiro 48:5562a99479e5 4424 break;
yabahiro 48:5562a99479e5 4425 case 1:
yabahiro 48:5562a99479e5 4426 motor[TIRE_BL].pwm += 5;
yabahiro 48:5562a99479e5 4427 mtc=false;
yabahiro 48:5562a99479e5 4428 break;
yabahiro 48:5562a99479e5 4429 case 3:
yabahiro 48:5562a99479e5 4430 motor[TIRE_BL].pwm += 10;
yabahiro 48:5562a99479e5 4431 mtc=false;
yabahiro 48:5562a99479e5 4432 break;
yabahiro 48:5562a99479e5 4433 case 2:
yabahiro 48:5562a99479e5 4434 motor[TIRE_BL].pwm += 20;
yabahiro 48:5562a99479e5 4435 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4436 mtc=false;
yabahiro 48:5562a99479e5 4437 break;
yabahiro 48:5562a99479e5 4438 }
yabahiro 48:5562a99479e5 4439 }
yabahiro 48:5562a99479e5 4440 }
yabahiro 48:5562a99479e5 4441 }
yabahiro 48:5562a99479e5 4442
yabahiro 48:5562a99479e5 4443 /*
yabahiro 48:5562a99479e5 4444 if(mode==31) {
yabahiro 48:5562a99479e5 4445 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4446 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4447 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4448 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4449 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4450 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4451 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4452 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4453 if(countss>=5000) {
yabahiro 48:5562a99479e5 4454 countss=0;
yabahiro 48:5562a99479e5 4455 mode=33;
yabahiro 48:5562a99479e5 4456 }
yabahiro 48:5562a99479e5 4457 } else if(mode==33) {
yabahiro 48:5562a99479e5 4458 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 4459 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4460 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4461 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4462 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4463 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4464 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 4465 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4466 if(g[3]==0) {
yabahiro 48:5562a99479e5 4467 cross=0;
yabahiro 48:5562a99479e5 4468 countss=0;
yabahiro 48:5562a99479e5 4469 mode=40;
yabahiro 48:5562a99479e5 4470 }
yabahiro 48:5562a99479e5 4471 } else
yabahiro 48:5562a99479e5 4472 */
yabahiro 48:5562a99479e5 4473 if(mode==31) {
yabahiro 48:5562a99479e5 4474 motor[TIRE_FR].pwm = 45;
yabahiro 48:5562a99479e5 4475 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4476 motor[TIRE_FL].pwm = 255;
yabahiro 48:5562a99479e5 4477 motor[TIRE_FL].dir = BRAKE;
yabahiro 48:5562a99479e5 4478 motor[TIRE_BR].pwm = 255;
yabahiro 48:5562a99479e5 4479 motor[TIRE_BR].dir = BRAKE;
yabahiro 48:5562a99479e5 4480 motor[TIRE_BL].pwm = 45;
yabahiro 48:5562a99479e5 4481 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4482 if(g[3]==0) {
yabahiro 48:5562a99479e5 4483 cross=0;
yabahiro 48:5562a99479e5 4484 countss=0;
yabahiro 48:5562a99479e5 4485 mode=40;
yabahiro 48:5562a99479e5 4486 }
yabahiro 48:5562a99479e5 4487 } else if(mode==40) {
yabahiro 48:5562a99479e5 4488 switch(g[3]) {
yabahiro 48:5562a99479e5 4489 case 98:
yabahiro 48:5562a99479e5 4490 motor[TIRE_FR].pwm = normal+15;
yabahiro 48:5562a99479e5 4491 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4492 motor[TIRE_FL].pwm = normal+15;
yabahiro 48:5562a99479e5 4493 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 4494 motor[TIRE_BR].pwm = normal+15;
yabahiro 48:5562a99479e5 4495 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 4496 motor[TIRE_BL].pwm = normal+15;
yabahiro 48:5562a99479e5 4497 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4498 if(countss>10000) {
yabahiro 48:5562a99479e5 4499 cross++;
yabahiro 48:5562a99479e5 4500 countss=0;
yabahiro 48:5562a99479e5 4501 }
yabahiro 48:5562a99479e5 4502 mtc2=true;
yabahiro 48:5562a99479e5 4503 if(cross==1) {
yabahiro 48:5562a99479e5 4504 mode=41;
yabahiro 48:5562a99479e5 4505 countss=0;
yabahiro 48:5562a99479e5 4506 cross=0;
yabahiro 48:5562a99479e5 4507 }
yabahiro 48:5562a99479e5 4508 break;
yabahiro 48:5562a99479e5 4509 case 0:
yabahiro 48:5562a99479e5 4510 motor[TIRE_FR].pwm = fast+15;
yabahiro 48:5562a99479e5 4511 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4512 motor[TIRE_FL].pwm = fast+15;
yabahiro 48:5562a99479e5 4513 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 4514 motor[TIRE_BR].pwm = fast+15;
yabahiro 48:5562a99479e5 4515 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 4516 motor[TIRE_BL].pwm = fast+15;
yabahiro 48:5562a99479e5 4517 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4518 mtc2=true;
yabahiro 48:5562a99479e5 4519 break;
yabahiro 48:5562a99479e5 4520 case 255:
yabahiro 48:5562a99479e5 4521 motor[TIRE_FR].pwm = slow+15;
yabahiro 48:5562a99479e5 4522 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4523 motor[TIRE_FL].pwm = fast+15;
yabahiro 48:5562a99479e5 4524 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 4525 motor[TIRE_BR].pwm = fast+15;
yabahiro 48:5562a99479e5 4526 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 4527 motor[TIRE_BL].pwm = slow+15;
yabahiro 48:5562a99479e5 4528 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4529 mtc2=true;
yabahiro 48:5562a99479e5 4530 break;
yabahiro 48:5562a99479e5 4531 case 253:
yabahiro 48:5562a99479e5 4532 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4533 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4534 motor[TIRE_FL].pwm = slow+15;
yabahiro 48:5562a99479e5 4535 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 4536 motor[TIRE_BR].pwm = slow+15;
yabahiro 48:5562a99479e5 4537 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 4538 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4539 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4540 mtc2=true;
yabahiro 48:5562a99479e5 4541 break;
yabahiro 48:5562a99479e5 4542 case 254:
yabahiro 48:5562a99479e5 4543 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4544 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4545 motor[TIRE_FL].pwm = normal+15;
yabahiro 48:5562a99479e5 4546 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 4547 motor[TIRE_BR].pwm = normal+15;
yabahiro 48:5562a99479e5 4548 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 4549 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4550 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4551 mtc2=true;
yabahiro 48:5562a99479e5 4552 break;
yabahiro 48:5562a99479e5 4553 case 1:
yabahiro 48:5562a99479e5 4554 motor[TIRE_FR].pwm = fast+15;
yabahiro 48:5562a99479e5 4555 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4556 motor[TIRE_FL].pwm = slow+15;
yabahiro 48:5562a99479e5 4557 motor[TIRE_FL].dir = BACK;
yabahiro 48:5562a99479e5 4558 motor[TIRE_BR].pwm = slow+15;
yabahiro 48:5562a99479e5 4559 motor[TIRE_BR].dir = FOR;
yabahiro 48:5562a99479e5 4560 motor[TIRE_BL].pwm = fast+15;
yabahiro 48:5562a99479e5 4561 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4562 mtc2=true;
yabahiro 48:5562a99479e5 4563 break;
yabahiro 48:5562a99479e5 4564 case 3:
yabahiro 48:5562a99479e5 4565 motor[TIRE_FR].pwm = slow+15;
yabahiro 48:5562a99479e5 4566 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4567 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4568 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4569 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4570 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4571 motor[TIRE_BL].pwm = slow+15;
yabahiro 48:5562a99479e5 4572 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4573 mtc2=true;
yabahiro 48:5562a99479e5 4574 break;
yabahiro 48:5562a99479e5 4575 case 2:
yabahiro 48:5562a99479e5 4576 motor[TIRE_FR].pwm = normal+15;
yabahiro 48:5562a99479e5 4577 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4578 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4579 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4580 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4581 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4582 motor[TIRE_BL].pwm = normal+15;
yabahiro 48:5562a99479e5 4583 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4584 mtc2=true;
yabahiro 48:5562a99479e5 4585 break;
yabahiro 48:5562a99479e5 4586 }
yabahiro 48:5562a99479e5 4587 if(g[2]!=98&&mtc2==true) {
yabahiro 48:5562a99479e5 4588 switch(g[2]) {
yabahiro 48:5562a99479e5 4589 case 0:
yabahiro 48:5562a99479e5 4590 mtc2=false;
yabahiro 48:5562a99479e5 4591 break;
yabahiro 48:5562a99479e5 4592 case 255:
yabahiro 48:5562a99479e5 4593 motor[TIRE_FL].pwm += 5;
yabahiro 48:5562a99479e5 4594 mtc2=false;
yabahiro 48:5562a99479e5 4595 break;
yabahiro 48:5562a99479e5 4596 case 253:
yabahiro 48:5562a99479e5 4597 motor[TIRE_FL].pwm += 10;
yabahiro 48:5562a99479e5 4598 mtc2=false;
yabahiro 48:5562a99479e5 4599 break;
yabahiro 48:5562a99479e5 4600 case 254:
yabahiro 48:5562a99479e5 4601 motor[TIRE_FL].pwm += 20;
yabahiro 48:5562a99479e5 4602 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4603 mtc2=false;
yabahiro 48:5562a99479e5 4604 break;
yabahiro 48:5562a99479e5 4605 case 1:
yabahiro 48:5562a99479e5 4606 motor[TIRE_BL].pwm += 5;
yabahiro 48:5562a99479e5 4607 mtc2=false;
yabahiro 48:5562a99479e5 4608 break;
yabahiro 48:5562a99479e5 4609 case 3:
yabahiro 48:5562a99479e5 4610 motor[TIRE_BL].pwm += 10;
yabahiro 48:5562a99479e5 4611 mtc2=false;
yabahiro 48:5562a99479e5 4612 break;
yabahiro 48:5562a99479e5 4613 case 2:
yabahiro 48:5562a99479e5 4614 motor[TIRE_BL].pwm += 20;
yabahiro 48:5562a99479e5 4615 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4616 mtc2=false;
yabahiro 48:5562a99479e5 4617 break;
yabahiro 48:5562a99479e5 4618 }
yabahiro 48:5562a99479e5 4619 }
yabahiro 48:5562a99479e5 4620 } else if(mode==41) {
yabahiro 48:5562a99479e5 4621 if(LIF||LIB) {
yabahiro 48:5562a99479e5 4622 mode=42;
yabahiro 48:5562a99479e5 4623 }
yabahiro 48:5562a99479e5 4624 motor[TIRE_FR].pwm = 30;
yabahiro 48:5562a99479e5 4625 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4626 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4627 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4628 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4629 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4630 motor[TIRE_BL].pwm = 30;
yabahiro 48:5562a99479e5 4631 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4632 if(g[1]==0) {
yabahiro 48:5562a99479e5 4633 countss=0;
yabahiro 48:5562a99479e5 4634 mode=70;
yabahiro 48:5562a99479e5 4635 normal=60;
yabahiro 48:5562a99479e5 4636 fast=70;
yabahiro 48:5562a99479e5 4637 slow=40;
yabahiro 48:5562a99479e5 4638 }
yabahiro 48:5562a99479e5 4639 } else if(mode==42) {
yabahiro 48:5562a99479e5 4640 motor[TIRE_FR].pwm = 40;
yabahiro 48:5562a99479e5 4641 motor[TIRE_FR].dir = FOR;
yabahiro 48:5562a99479e5 4642 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4643 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4644 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4645 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4646 motor[TIRE_BL].pwm = 40;
yabahiro 48:5562a99479e5 4647 motor[TIRE_BL].dir = BACK;
yabahiro 48:5562a99479e5 4648 if(g[1]==0) {
yabahiro 48:5562a99479e5 4649 countss=0;
yabahiro 48:5562a99479e5 4650 mode=70;
yabahiro 48:5562a99479e5 4651 }
yabahiro 48:5562a99479e5 4652 } else if(mode==70) {
yabahiro 48:5562a99479e5 4653 switch(g[0]) {
yabahiro 48:5562a99479e5 4654 case 99:
yabahiro 48:5562a99479e5 4655 if(countss>=100000) {
yabahiro 48:5562a99479e5 4656 mode=100;
yabahiro 48:5562a99479e5 4657 }
yabahiro 48:5562a99479e5 4658 break;
yabahiro 48:5562a99479e5 4659 case 98:
yabahiro 48:5562a99479e5 4660 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4661 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4662 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4663 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4664 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4665 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4666 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4667 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4668 break;
yabahiro 48:5562a99479e5 4669 case 0:
yabahiro 48:5562a99479e5 4670 motor[TIRE_FR].pwm = 80;
yabahiro 48:5562a99479e5 4671 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4672 motor[TIRE_FL].pwm = 80;
yabahiro 48:5562a99479e5 4673 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4674 motor[TIRE_BR].pwm = 80;
yabahiro 48:5562a99479e5 4675 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4676 motor[TIRE_BL].pwm = 80;
yabahiro 48:5562a99479e5 4677 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4678 mtc=true;
yabahiro 48:5562a99479e5 4679 break;
yabahiro 48:5562a99479e5 4680 case 255:
yabahiro 48:5562a99479e5 4681 motor[TIRE_FR].pwm = fast;
yabahiro 48:5562a99479e5 4682 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4683 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4684 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4685 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4686 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4687 motor[TIRE_BL].pwm = fast;
yabahiro 48:5562a99479e5 4688 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4689 mtc=true;
yabahiro 48:5562a99479e5 4690 break;
yabahiro 48:5562a99479e5 4691 case 253:
yabahiro 48:5562a99479e5 4692 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4693 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4694 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4695 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4696 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4697 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4698 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4699 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4700 mtc=true;
yabahiro 48:5562a99479e5 4701 break;
yabahiro 48:5562a99479e5 4702 case 254:
yabahiro 48:5562a99479e5 4703 motor[TIRE_FR].pwm = normal;
yabahiro 48:5562a99479e5 4704 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4705 motor[TIRE_FL].pwm = 0;
yabahiro 48:5562a99479e5 4706 motor[TIRE_FL].dir = FREE;
yabahiro 48:5562a99479e5 4707 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4708 motor[TIRE_BR].dir = FREE;
yabahiro 48:5562a99479e5 4709 motor[TIRE_BL].pwm = normal;
yabahiro 48:5562a99479e5 4710 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4711 mtc=true;
yabahiro 48:5562a99479e5 4712 break;
yabahiro 48:5562a99479e5 4713 case 1:
yabahiro 48:5562a99479e5 4714 motor[TIRE_FR].pwm = slow;
yabahiro 48:5562a99479e5 4715 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4716 motor[TIRE_FL].pwm = fast;
yabahiro 48:5562a99479e5 4717 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4718 motor[TIRE_BR].pwm = fast;
yabahiro 48:5562a99479e5 4719 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4720 motor[TIRE_BL].pwm = slow;
yabahiro 48:5562a99479e5 4721 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4722 mtc=true;
yabahiro 48:5562a99479e5 4723 break;
yabahiro 48:5562a99479e5 4724 case 3:
yabahiro 48:5562a99479e5 4725 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4726 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4727 motor[TIRE_FL].pwm = slow;
yabahiro 48:5562a99479e5 4728 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4729 motor[TIRE_BR].pwm = slow;
yabahiro 48:5562a99479e5 4730 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4731 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4732 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4733 mtc=true;
yabahiro 48:5562a99479e5 4734 break;
yabahiro 48:5562a99479e5 4735 case 2:
yabahiro 48:5562a99479e5 4736 motor[TIRE_FR].pwm = 0;
yabahiro 48:5562a99479e5 4737 motor[TIRE_FR].dir = FREE;
yabahiro 48:5562a99479e5 4738 motor[TIRE_FL].pwm = normal;
yabahiro 48:5562a99479e5 4739 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4740 motor[TIRE_BR].pwm = normal;
yabahiro 48:5562a99479e5 4741 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4742 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4743 motor[TIRE_BL].dir = FREE;
yabahiro 48:5562a99479e5 4744 mtc=true;
yabahiro 48:5562a99479e5 4745 break;
yabahiro 48:5562a99479e5 4746 }
yabahiro 48:5562a99479e5 4747 if(g[1]!=98&&mtc==true) {
yabahiro 48:5562a99479e5 4748 switch(g[1]) {
yabahiro 48:5562a99479e5 4749 case 0:
yabahiro 48:5562a99479e5 4750 mtc=false;
yabahiro 48:5562a99479e5 4751 break;
yabahiro 48:5562a99479e5 4752 case 255:
yabahiro 48:5562a99479e5 4753 motor[TIRE_BR].pwm += 5;
yabahiro 48:5562a99479e5 4754 mtc=false;
yabahiro 48:5562a99479e5 4755 break;
yabahiro 48:5562a99479e5 4756 case 253:
yabahiro 48:5562a99479e5 4757 motor[TIRE_BR].pwm += 10;
yabahiro 48:5562a99479e5 4758 mtc=false;
yabahiro 48:5562a99479e5 4759 break;
yabahiro 48:5562a99479e5 4760 case 254:
yabahiro 48:5562a99479e5 4761 motor[TIRE_BR].pwm += 20;
yabahiro 48:5562a99479e5 4762 motor[TIRE_BL].pwm = 0;
yabahiro 48:5562a99479e5 4763 mtc=false;
yabahiro 48:5562a99479e5 4764 break;
yabahiro 48:5562a99479e5 4765 case 1:
yabahiro 48:5562a99479e5 4766 motor[TIRE_BL].pwm += 5;
yabahiro 48:5562a99479e5 4767 mtc=false;
yabahiro 48:5562a99479e5 4768 break;
yabahiro 48:5562a99479e5 4769 case 3:
yabahiro 48:5562a99479e5 4770 motor[TIRE_BL].pwm += 10;
yabahiro 48:5562a99479e5 4771 mtc=false;
yabahiro 48:5562a99479e5 4772 break;
yabahiro 48:5562a99479e5 4773 case 2:
yabahiro 48:5562a99479e5 4774 motor[TIRE_BL].pwm += 20;
yabahiro 48:5562a99479e5 4775 motor[TIRE_BR].pwm = 0;
yabahiro 48:5562a99479e5 4776 mtc=false;
yabahiro 48:5562a99479e5 4777 break;
yabahiro 48:5562a99479e5 4778 }
yabahiro 48:5562a99479e5 4779 }
yabahiro 48:5562a99479e5 4780 } else if(mode==100) {
yabahiro 48:5562a99479e5 4781 motor[TIRE_FR].pwm = 50;
yabahiro 48:5562a99479e5 4782 motor[TIRE_FR].dir = BACK;
yabahiro 48:5562a99479e5 4783 motor[TIRE_FL].pwm = 50;
yabahiro 48:5562a99479e5 4784 motor[TIRE_FL].dir = FOR;
yabahiro 48:5562a99479e5 4785 motor[TIRE_BR].pwm = 50;
yabahiro 48:5562a99479e5 4786 motor[TIRE_BR].dir = BACK;
yabahiro 48:5562a99479e5 4787 motor[TIRE_BL].pwm = 50;
yabahiro 48:5562a99479e5 4788 motor[TIRE_BL].dir = FOR;
yabahiro 48:5562a99479e5 4789 } else {
yabahiro 48:5562a99479e5 4790 }
yabahiro 33:dd598bb23ad1 4791
kishibekairohan 13:b6e02d6261d7 4792 }
kishibekairohan 13:b6e02d6261d7 4793 #endif
kishibekairohan 13:b6e02d6261d7 4794
kishibekairohan 13:b6e02d6261d7 4795 #if USE_PROCESS_NUM>5
Ryosei 27:dd9f27fce7d1 4796 static void Process5()
Ryosei 27:dd9f27fce7d1 4797 {
yabahiro 46:68296caae1af 4798
kishibekairohan 13:b6e02d6261d7 4799 }
kishibekairohan 13:b6e02d6261d7 4800 #endif
kishibekairohan 13:b6e02d6261d7 4801
kishibekairohan 13:b6e02d6261d7 4802 #if USE_PROCESS_NUM>6
Ryosei 27:dd9f27fce7d1 4803 static void Process6()
kishibekairohan 13:b6e02d6261d7 4804 {
Ryosei 27:dd9f27fce7d1 4805
kishibekairohan 13:b6e02d6261d7 4806 }
kishibekairohan 13:b6e02d6261d7 4807 #endif
kishibekairohan 13:b6e02d6261d7 4808
kishibekairohan 13:b6e02d6261d7 4809 #if USE_PROCESS_NUM>7
kishibekairohan 13:b6e02d6261d7 4810 static void Process7()
kishibekairohan 13:b6e02d6261d7 4811 {
yabahiro 33:dd598bb23ad1 4812
kishibekairohan 12:c09b3e08a316 4813 }
kishibekairohan 12:c09b3e08a316 4814 #endif
kishibekairohan 12:c09b3e08a316 4815
Ryosei 27:dd9f27fce7d1 4816 #if USE_PROCESS_NUM>8
kishibekairohan 13:b6e02d6261d7 4817 static void Process8()
kishibekairohan 12:c09b3e08a316 4818 {
yabahiro 33:dd598bb23ad1 4819
kishibekairohan 12:c09b3e08a316 4820 }
kishibekairohan 12:c09b3e08a316 4821 #endif
kishibekairohan 12:c09b3e08a316 4822
kishibekairohan 13:b6e02d6261d7 4823 #if USE_PROCESS_NUM>9
kishibekairohan 13:b6e02d6261d7 4824 static void Process9()
kishibekairohan 12:c09b3e08a316 4825 {
Ryosei 27:dd9f27fce7d1 4826
t_yamamoto 0:669ef71cba68 4827 }
t_yamamoto 0:669ef71cba68 4828 #endif
t_yamamoto 0:669ef71cba68 4829 #endif
t_yamamoto 0:669ef71cba68 4830 #pragma endregion PROCESS
t_yamamoto 0:669ef71cba68 4831
t_yamamoto 0:669ef71cba68 4832 static void AllActuatorReset()
t_yamamoto 0:669ef71cba68 4833 {
yabahiro 33:dd598bb23ad1 4834 #ifdef USE_SOLENOID
yabahiro 33:dd598bb23ad1 4835 solenoid.all = ALL_SOLENOID_OFF;
yabahiro 33:dd598bb23ad1 4836 #endif
yabahiro 33:dd598bb23ad1 4837
yabahiro 33:dd598bb23ad1 4838 #ifdef USE_MOTOR
yabahiro 33:dd598bb23ad1 4839 for (uint8_t i = 0; i < MOUNTING_MOTOR_NUM; i++) {
yabahiro 33:dd598bb23ad1 4840 motor[i].dir = FREE;
yabahiro 33:dd598bb23ad1 4841 motor[i].pwm = 0;
yabahiro 33:dd598bb23ad1 4842 }
yabahiro 33:dd598bb23ad1 4843 #endif
t_yamamoto 0:669ef71cba68 4844 }
t_yamamoto 0:669ef71cba68 4845
kishibekairohan 16:3f2c2d89372b 4846 #pragma region USER-DEFINED-FUNCTIONS
M_souta 29:44d5454ce8fa 4847
M_souta 29:44d5454ce8fa 4848 uint8_t SetStatus(int pwmVal)
Ryosei 27:dd9f27fce7d1 4849 {
M_souta 29:44d5454ce8fa 4850 if (pwmVal < 0) return BACK;
M_souta 29:44d5454ce8fa 4851 else if (pwmVal > 0) return FOR;
M_souta 29:44d5454ce8fa 4852 else if (pwmVal == 0) return BRAKE;
M_souta 29:44d5454ce8fa 4853 else return BRAKE;
M_souta 22:7d93f79a3686 4854 }
kishibekairohan 16:3f2c2d89372b 4855
M_souta 29:44d5454ce8fa 4856 uint8_t SetPWM(int pwmVal)
Ryosei 27:dd9f27fce7d1 4857 {
M_souta 29:44d5454ce8fa 4858 if (pwmVal == 0 || pwmVal > 255 || pwmVal < -255) return 255;
M_souta 29:44d5454ce8fa 4859 else return abs(pwmVal);
M_souta 22:7d93f79a3686 4860 }
kishibekairohan 16:3f2c2d89372b 4861
t_yamamoto 0:669ef71cba68 4862 #pragma endregion