aa

Dependencies:   mbed

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