aaaaa

Dependencies:   mbed Servo

Committer:
niimurasyou
Date:
Mon Feb 25 05:48:20 2019 +0000
Revision:
11:88f17bc0724f
Parent:
10:a765515594bd
Child:
12:8321e464475f
hhhhhhhhh

Who changed what in which revision?

UserRevisionLine numberNew contents of line
niimurasyou 10:a765515594bd 1
t_yamamoto 8:cb53beff4bb2 2 //2018/02/24のやつ
t_yamamoto 5:a802ab60df1b 3
t_yamamoto 0:562021ed1ba9 4 #include "Process.h"
t_yamamoto 0:562021ed1ba9 5 #include "mbed.h"
t_yamamoto 0:562021ed1ba9 6 #include "../../Communication/XBee/XBee.h"
t_yamamoto 0:562021ed1ba9 7 #include "../../Input/Switch/Switch.h"
t_yamamoto 0:562021ed1ba9 8 #include "../../Output/Motor/Motor.h"
t_yamamoto 8:cb53beff4bb2 9 #include "../../Output/Servo/Servo.h"
t_yamamoto 8:cb53beff4bb2 10
t_yamamoto 0:562021ed1ba9 11 //_____________________
t_yamamoto 0:562021ed1ba9 12 /*---------------- HOW TO WRITE ----------------/
t_yamamoto 0:562021ed1ba9 13
t_yamamoto 0:562021ed1ba9 14 ・motor の割り当てを決める
t_yamamoto 0:562021ed1ba9 15 #define TIRE_L 1
t_yamamoto 0:562021ed1ba9 16
t_yamamoto 0:562021ed1ba9 17 ・リミットスイッチの割り当てを決める
t_yamamoto 0:562021ed1ba9 18 #define ARM_L 1
t_yamamoto 0:562021ed1ba9 19
t_yamamoto 0:562021ed1ba9 20 ・他にも自由に定義してもいいです (pwmとか)
t_yamamoto 0:562021ed1ba9 21
t_yamamoto 0:562021ed1ba9 22 /---------------- HOW TO WRITE ----------------*/
t_yamamoto 0:562021ed1ba9 23 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
t_yamamoto 0:562021ed1ba9 24
niimurasyou 9:ec30ae33cc9e 25 #define a 0
niimurasyou 9:ec30ae33cc9e 26 #define b 1
niimurasyou 9:ec30ae33cc9e 27 #define c 2
niimurasyou 11:88f17bc0724f 28 #define d 3
niimurasyou 11:88f17bc0724f 29 #define e 4
niimurasyou 11:88f17bc0724f 30 #define ARMlim 0
niimurasyou 11:88f17bc0724f 31 #define lim 1
niimurasyou 9:ec30ae33cc9e 32
niimurasyou 9:ec30ae33cc9e 33
niimurasyou 11:88f17bc0724f 34 int Air0=0;
niimurasyou 11:88f17bc0724f 35 int Air1=1;
niimurasyou 11:88f17bc0724f 36 int homes=0;
niimurasyou 11:88f17bc0724f 37
niimurasyou 11:88f17bc0724f 38
niimurasyou 11:88f17bc0724f 39
niimurasyou 11:88f17bc0724f 40 //////////////////関数、タイマーの宣言///////////////
niimurasyou 11:88f17bc0724f 41 DigitalOut Air[]= {
niimurasyou 11:88f17bc0724f 42 DigitalOut(A5),
niimurasyou 11:88f17bc0724f 43 DigitalOut(A4),
niimurasyou 11:88f17bc0724f 44 };
niimurasyou 11:88f17bc0724f 45 Timer Airtime;
niimurasyou 11:88f17bc0724f 46 Timer home;
niimurasyou 11:88f17bc0724f 47 void AirOut(int pin,int mode)
niimurasyou 11:88f17bc0724f 48 {
niimurasyou 11:88f17bc0724f 49 Air[pin]=mode;
niimurasyou 11:88f17bc0724f 50 }
niimurasyou 11:88f17bc0724f 51 ////////////
niimurasyou 11:88f17bc0724f 52 float s=Airtime.read();//エアータイム
niimurasyou 11:88f17bc0724f 53
niimurasyou 9:ec30ae33cc9e 54 int a_array[15][15] = {
niimurasyou 10:a765515594bd 55 {-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80},
niimurasyou 10:a765515594bd 56 {-79, -69, -55, -47, -35, -20, -10, 0, 10, 20, 35, 47, 55, 69, 79},
niimurasyou 10:a765515594bd 57 {-77, -68, -50, -45, -30, -20, -10, 0, 10, 20, 30, 45, 50, 68, 77},
niimurasyou 10:a765515594bd 58 {-75, -67, -49, -40, -25, -20, -10, 0, 10, 20, 25, 40, 49, 67, 75},
niimurasyou 10:a765515594bd 59 {-73, -66, -48, -37, -20, -20, -10, 0, 10, 20, 20, 37, 48, 66, 73},
niimurasyou 10:a765515594bd 60 {-71, -62, -46, -32, -20, -10, 0 , 0, 0 , 10, 20, 32, 46, 62, 71},
niimurasyou 10:a765515594bd 61 {-70, -60, -45, -30, -20, -10, 0 , 0, 0 , 10, 20, 30, 45, 60, 70},
niimurasyou 10:a765515594bd 62 {-71, -62, -46, -32, 10 , -10, 0 , 0, 0 , 10, 20, 32, 46, 62, 71},
niimurasyou 10:a765515594bd 63 {-72, -64, -47, -35, 20 , -10, -10, 0, 10, 10, 20, 35, 47, 64, 72},
niimurasyou 10:a765515594bd 64 {-73, -66, -48, -37, -20, -20, -10, 0, 10, 20, 20, 37, 48, 66, 73},
niimurasyou 10:a765515594bd 65 {-75, -67, -49, -40, 40 , -20, -10, 0, 10, 20, 25, 40, 49, 67, 75},
niimurasyou 10:a765515594bd 66 {-77, -68, -50, -45, 60 , -20, -10, 0, 10, 20, 30, 45, 50, 68, 77},
niimurasyou 10:a765515594bd 67 {-79, -69, -55, -47, 70 , -20, -10, 0, 10, 20, 35, 47, 55, 69, 79},
niimurasyou 11:88f17bc0724f 68 {-80, -70, -60, -50, -40, -20, -10, 0, 10, 20, 40, 50, 60, 70, 80},
niimurasyou 11:88f17bc0724f 69 {-80, -70, -60, -50, -40, -20,s-10, 0, 10, 20, 40, 50, 60, 70, 80}};
niimurasyou 9:ec30ae33cc9e 70
niimurasyou 9:ec30ae33cc9e 71 int b_array[15][15] = {
niimurasyou 10:a765515594bd 72 {80, 80, 80 , 77 , 75 , 72 , 71 , 70, 60, 50, 40, 30, 20, 10, 0},
niimurasyou 10:a765515594bd 73 {80, 80, 75 , 70 , 65 , 60 , 55 , 50, 45, 40, 30, 20, 10, 0 , -10},
niimurasyou 10:a765515594bd 74 {80, 71, 70 , 60 , 55 , 50 , 45 , 40, 35, 30, 20, 10, 0, -10, -13},
niimurasyou 10:a765515594bd 75 {60, 60, 57 , 50 , 45 , 40 , 35 , 30, 25, 20, 10, 0 , -10, -13, -17},
niimurasyou 10:a765515594bd 76 {50, 50, 50 , 40 , 35 , 30 , 23 , 20, 15, 10, 0 , -10, -15, -17, -20},
niimurasyou 10:a765515594bd 77 {45, 45, 43 , 35 , 30 , 25 , 10 , 10, 10, 0 , -10, -15, -20, -20, -25},
niimurasyou 10:a765515594bd 78 {40, 37, 35 , 30 , 25 , 20 , 0 , 0 , 0 , -10, -15, -20, -25, -25, -30},
niimurasyou 10:a765515594bd 79 {35, 30, 30 , 25 , 20 , 15 , 0 , 0 , 0 , -15, -20, -25, -30, -30, -35},
niimurasyou 10:a765515594bd 80 {30, 25, 25 , 20 , 15 , 10 , 0 , 0 , 0 , -20, -25, -30, -35, -37, -40},
niimurasyou 10:a765515594bd 81 {20, 17, 15 , 10 , 0 , -10, -15,-20, -23, -30 ,-35 ,-40 ,-50 ,-50 , -50},
niimurasyou 10:a765515594bd 82 {17, 13, 10 , 0 , -10, -20, -25,-30, -35, -40 ,-45 ,-50 ,-57 ,-60 , -60},
niimurasyou 10:a765515594bd 83 {13, 10, 0 , -10, -20, -30, -35,-40, -45, -50 ,-55 ,-60 , -70, -71, -80},
niimurasyou 10:a765515594bd 84 {10, 0 , -10, -20, -30, -40, -45,-50, -55, -60 ,-65 ,-70 ,-75 ,-80 , -80},
niimurasyou 11:88f17bc0724f 85 {0 , -10, -20, -30, -40, -50, -60,-70, -71, -72 ,-75 ,-77 ,-80 ,-80 , -80},
niimurasyou 10:a765515594bd 86 {0 , -10, -20, -30, -40, -50, -60,-70, -71, -72 ,-75 ,-77 ,-80 ,-80 , -80}};
niimurasyou 10:a765515594bd 87
niimurasyou 10:a765515594bd 88 int c_array[15][15] = {
niimurasyou 10:a765515594bd 89 {0, 10, 20 , 30 , 40 , 50 , 60 ,70 , 71, 72 , 75 , 77 , 80 , 80 , 80},
niimurasyou 10:a765515594bd 90 {-10, 0 , 10 , 20 , 30 , 40 , 45 ,50 , 55 , 60 ,65 ,70 ,75 ,80 ,80},
niimurasyou 10:a765515594bd 91 {-13, -10, 0 , 10 , 20 , 30 , 35 ,40 , 45 , 50 ,55 ,60 ,70 ,71 ,80},
niimurasyou 10:a765515594bd 92 {-17, -13, -10, 0 , 10 , 20 , 25 ,30 , 35 , 40 ,45 ,50 ,57 ,60 ,60},
niimurasyou 10:a765515594bd 93 {-20, -17, -15, -10, 0 , 10 , 15 ,20 , 23 , 30 ,35 ,40 ,50 ,50 ,50},
niimurasyou 10:a765515594bd 94 {-25, -20, -20, -15, -10, 0 , 10 ,10 , 10 , 25 ,30 ,35 ,43 ,45 ,45},
niimurasyou 10:a765515594bd 95 {-30, -25, -25, -20, -15, -10, 0 ,0 , 0 , 20 ,25 ,30 ,35 ,37 ,40},
niimurasyou 10:a765515594bd 96 {-35, -30, -30, -25, -20, -15, 0 ,0 , 0 , 15 ,20 ,25 ,30 ,30 ,35},
niimurasyou 10:a765515594bd 97 {-40, -37, -35, -30, -25, -20, 0 ,0 , 0 , 10 ,15 ,20 ,25 ,25 ,30},
niimurasyou 10:a765515594bd 98 {-50, -50, -50, -40, -35, -30, -23,-20, -15, -10 ,0 ,10 ,15 ,17 ,20},
niimurasyou 10:a765515594bd 99 {-60, -60, -57, -50, -45, -40, -35,-30, -25, -20 ,-10 ,0 ,10 ,13 ,17},
niimurasyou 10:a765515594bd 100 {-80, -71, -70, -60, -55, -50, -45,-40, -35, -30 ,-20 ,-10 ,0 ,10 ,13},
niimurasyou 10:a765515594bd 101 {-80, -80, -75, -70, -65, -60, -55,-50, -45, -40 ,-30 ,-20 ,-10 ,0 ,10},
niimurasyou 11:88f17bc0724f 102 {-80, -80, -80, -77, -75, -72, -71,-70, -60, -50 ,-40 ,-30 ,-20 ,-10 ,0},
niimurasyou 10:a765515594bd 103 {-80, -80, -80, -77, -75, -72, -71,-70, -60, -50 ,-40 ,-30 ,-20 ,-10 ,0}};
t_yamamoto 0:562021ed1ba9 104
t_yamamoto 0:562021ed1ba9 105
niimurasyou 10:a765515594bd 106
niimurasyou 10:a765515594bd 107
niimurasyou 10:a765515594bd 108
t_yamamoto 0:562021ed1ba9 109
niimurasyou 9:ec30ae33cc9e 110 #define usiro 0
niimurasyou 9:ec30ae33cc9e 111 #define mae 0
niimurasyou 9:ec30ae33cc9e 112 uint8_t motorData[5];
niimurasyou 9:ec30ae33cc9e 113 uint8_t pwmData[5];
niimurasyou 9:ec30ae33cc9e 114
niimurasyou 9:ec30ae33cc9e 115 int conlx;
niimurasyou 9:ec30ae33cc9e 116 int conly;
niimurasyou 9:ec30ae33cc9e 117 int conrx;
niimurasyou 9:ec30ae33cc9e 118 int conry;
niimurasyou 11:88f17bc0724f 119
niimurasyou 11:88f17bc0724f 120 int mode=0;
t_yamamoto 0:562021ed1ba9 121
t_yamamoto 0:562021ed1ba9 122 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
t_yamamoto 0:562021ed1ba9 123 //_____________________
t_yamamoto 0:562021ed1ba9 124
t_yamamoto 8:cb53beff4bb2 125 //#define USE_USB_SERIAL
t_yamamoto 0:562021ed1ba9 126 #ifdef USE_USB_SERIAL
t_yamamoto 0:562021ed1ba9 127 Serial pc(SERIAL_TX, SERIAL_RX);
t_yamamoto 0:562021ed1ba9 128 #endif
t_yamamoto 0:562021ed1ba9 129 XBEE::ControllerData *controller;
t_yamamoto 0:562021ed1ba9 130 MOTOR::MotorStatus motor[MOUNTING_MOTOR_NUM];
t_yamamoto 0:562021ed1ba9 131
t_yamamoto 0:562021ed1ba9 132 using namespace SWITCH;
t_yamamoto 0:562021ed1ba9 133
t_yamamoto 8:cb53beff4bb2 134 void SystemProcess(void) {
t_yamamoto 0:562021ed1ba9 135 while(true) {
t_yamamoto 0:562021ed1ba9 136 controller = XBEE::Controller::GetData();
t_yamamoto 0:562021ed1ba9 137 //____________________________
t_yamamoto 0:562021ed1ba9 138 /*------------------------ HOW TO WRITE ------------------------/
t_yamamoto 0:562021ed1ba9 139
t_yamamoto 0:562021ed1ba9 140 ここにメインのプログラムを書く
t_yamamoto 0:562021ed1ba9 141
t_yamamoto 0:562021ed1ba9 142 ・コントローラから受け取ったデータをもとに動作のプログラムを書く
t_yamamoto 0:562021ed1ba9 143 (コントローラのデータは controller-> で取る)
t_yamamoto 0:562021ed1ba9 144
t_yamamoto 0:562021ed1ba9 145 if(controller->Button.RIGHT) {
t_yamamoto 0:562021ed1ba9 146 motor[TIRE_L].dir = FOR;
t_yamamoto 0:562021ed1ba9 147 motor[TIRE_R].dir = BACK;
t_yamamoto 7:f4252ddc480d 148 motor[TIRE_L].pwm = 12.3;
t_yamamoto 7:f4252ddc480d 149 motor[TIRE_R].pwm = 12.3;
t_yamamoto 0:562021ed1ba9 150 }
t_yamamoto 0:562021ed1ba9 151
t_yamamoto 6:c294736ba99d 152 motor[0].dirは FOR (正転)
t_yamamoto 0:562021ed1ba9 153 BACK (逆転)
t_yamamoto 0:562021ed1ba9 154 BRAKE (ブレーキ)
t_yamamoto 0:562021ed1ba9 155 FREE (フリー)
t_yamamoto 0:562021ed1ba9 156
t_yamamoto 0:562021ed1ba9 157 motor[0].pwmは 0.0(%) ~ 100.0(%)
t_yamamoto 0:562021ed1ba9 158
t_yamamoto 0:562021ed1ba9 159 controllerは XBee.hの構造体の中身
t_yamamoto 0:562021ed1ba9 160
t_yamamoto 0:562021ed1ba9 161 (AnalogL・Rを使いたかったら、頑張って考える or 聞いてください)
t_yamamoto 0:562021ed1ba9 162
t_yamamoto 0:562021ed1ba9 163 ・リミットスイッチの値をもとに動作のプログラムを書く
t_yamamoto 0:562021ed1ba9 164
t_yamamoto 0:562021ed1ba9 165 if(Switch::CheckPushed(ARM_L))
t_yamamoto 0:562021ed1ba9 166 {
t_yamamoto 0:562021ed1ba9 167 if(controller->Button.L)
t_yamamoto 0:562021ed1ba9 168 {
t_yamamoto 6:c294736ba99d 169 motor[ARM].dir = FOR;
t_yamamoto 0:562021ed1ba9 170 motor[ARM].pwm = 80.0;
t_yamamoto 0:562021ed1ba9 171 }
t_yamamoto 0:562021ed1ba9 172 if(motor[ARM].dir == BACK)
t_yamamoto 0:562021ed1ba9 173 {
t_yamamoto 0:562021ed1ba9 174 motor[ARM].dir = BRAKE;
t_yamamoto 0:562021ed1ba9 175 }
t_yamamoto 0:562021ed1ba9 176 }
t_yamamoto 0:562021ed1ba9 177
t_yamamoto 0:562021ed1ba9 178 →関数 Switch::CheckPushed の引数はリミットスイッチの名前 (limitSw[0]みたいな), 返り値はbool型 (true or false)
t_yamamoto 0:562021ed1ba9 179
t_yamamoto 0:562021ed1ba9 180 ・他にもやりたいことがあったら自由にどうぞ
t_yamamoto 0:562021ed1ba9 181
t_yamamoto 0:562021ed1ba9 182 ps.わからないことがあったら聞いてください
t_yamamoto 0:562021ed1ba9 183
t_yamamoto 0:562021ed1ba9 184 /------------------------ HOW TO WRITE ------------------------*/
t_yamamoto 0:562021ed1ba9 185 //↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
t_yamamoto 0:562021ed1ba9 186
niimurasyou 9:ec30ae33cc9e 187 conlx = controller->AnalogL.X;
niimurasyou 9:ec30ae33cc9e 188 conly = controller->AnalogL.Y;
niimurasyou 9:ec30ae33cc9e 189 conrx = controller->AnalogR.X;
niimurasyou 9:ec30ae33cc9e 190 conry = controller->AnalogR.Y;
niimurasyou 9:ec30ae33cc9e 191 //conba = controller->Button.A;
niimurasyou 9:ec30ae33cc9e 192 //conbb = controller->Button.B;
niimurasyou 9:ec30ae33cc9e 193 //conby = controller->Button.Y;
niimurasyou 9:ec30ae33cc9e 194 //conbx = controller->Button.X;
t_yamamoto 0:562021ed1ba9 195
niimurasyou 9:ec30ae33cc9e 196 if(a_array[conly][conlx]<0){
niimurasyou 11:88f17bc0724f 197 motor[a].pwm = (-1*a_array[conly][conlx]*100)/80;
niimurasyou 9:ec30ae33cc9e 198 motor[a].dir = FOR;
niimurasyou 9:ec30ae33cc9e 199 }else if(a_array[conly][conlx] > 0){
niimurasyou 11:88f17bc0724f 200 motor[a].pwm = (a_array[conly][conlx]*100)/80;
niimurasyou 11:88f17bc0724f 201 motor[a].dir = BACK;
niimurasyou 9:ec30ae33cc9e 202 }else if(a_array[conly][conlx] == 0){
niimurasyou 9:ec30ae33cc9e 203 if(conry < 6){
niimurasyou 9:ec30ae33cc9e 204 motor[a].dir = BACK;
niimurasyou 9:ec30ae33cc9e 205 motor[b].dir = BACK;
niimurasyou 9:ec30ae33cc9e 206 motor[c].dir = BACK;
niimurasyou 9:ec30ae33cc9e 207 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 208 motor[b].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 209 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 210 }else if(conry > 8){
niimurasyou 9:ec30ae33cc9e 211 motor[a].dir = FOR;
niimurasyou 9:ec30ae33cc9e 212 motor[b].dir = FOR;
niimurasyou 9:ec30ae33cc9e 213 motor[c].dir = FOR;
niimurasyou 9:ec30ae33cc9e 214 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 215 motor[b].pwm = 100.0;
niimurasyou 11:88f17bc0724f 216 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 217 }else{
niimurasyou 9:ec30ae33cc9e 218 motor[a].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 219 motor[b].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 220 motor[c].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 221 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 222 motor[b].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 223 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 224 }
niimurasyou 9:ec30ae33cc9e 225 }
niimurasyou 9:ec30ae33cc9e 226
niimurasyou 9:ec30ae33cc9e 227 if(b_array[conly][conlx] <0 ){
niimurasyou 11:88f17bc0724f 228 motor[b].pwm = (-1*b_array[conly][conlx]*100)/80;
niimurasyou 9:ec30ae33cc9e 229 motor[b].dir = FOR;
niimurasyou 9:ec30ae33cc9e 230 }else if(b_array[conly][conlx] > 0){
niimurasyou 11:88f17bc0724f 231 motor[b].pwm = (b_array[conly][conlx]*100)/80;
niimurasyou 11:88f17bc0724f 232 motor[b].dir = BACK;
niimurasyou 9:ec30ae33cc9e 233 }else if(a_array[conly][conlx] == 0 ){
niimurasyou 9:ec30ae33cc9e 234 if(conrx < 6 ) {
niimurasyou 11:88f17bc0724f 235 motor[a].dir = BACK;
niimurasyou 11:88f17bc0724f 236 motor[b].dir = BACK;
niimurasyou 11:88f17bc0724f 237 motor[c].dir = BACK;
niimurasyou 11:88f17bc0724f 238 motor[a].pwm = 100.0;
niimurasyou 11:88f17bc0724f 239 motor[b].pwm = 100.0;
niimurasyou 11:88f17bc0724f 240 motor[c].pwm = 100.0;
niimurasyou 11:88f17bc0724f 241 }else if(conrx > 8){
niimurasyou 11:88f17bc0724f 242 motor[a].dir = FOR;
niimurasyou 11:88f17bc0724f 243 motor[b].dir = FOR;
niimurasyou 11:88f17bc0724f 244 motor[c].dir = FOR;
niimurasyou 11:88f17bc0724f 245 motor[a].pwm = 100.0;
niimurasyou 11:88f17bc0724f 246 motor[b].pwm = 100.0;
niimurasyou 11:88f17bc0724f 247 motor[c].pwm = 100.0;
niimurasyou 11:88f17bc0724f 248 }else{
niimurasyou 9:ec30ae33cc9e 249 motor[a].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 250 motor[b].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 251 motor[c].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 252 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 253 motor[b].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 254 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 255 }
niimurasyou 11:88f17bc0724f 256 }
niimurasyou 9:ec30ae33cc9e 257
niimurasyou 9:ec30ae33cc9e 258 if(c_array[conly][conlx] <0 ){
niimurasyou 11:88f17bc0724f 259 motor[c].pwm =(-1*c_array[conly][conlx]*100)/80;
niimurasyou 11:88f17bc0724f 260 motor[c].dir = BACK;
niimurasyou 9:ec30ae33cc9e 261 }else if(c_array[conly][conlx] > 0){
niimurasyou 11:88f17bc0724f 262 motor[c].pwm =(c_array[conly][conlx]*100)/80;
niimurasyou 9:ec30ae33cc9e 263 motor[c].dir = FOR;
niimurasyou 9:ec30ae33cc9e 264 }else if(a_array[conly][conlx] == 0 ){
niimurasyou 9:ec30ae33cc9e 265 if(conrx < 6 ) {
niimurasyou 9:ec30ae33cc9e 266 motor[a].dir = BACK;
niimurasyou 9:ec30ae33cc9e 267 motor[b].dir = BACK;
niimurasyou 9:ec30ae33cc9e 268 motor[c].dir = BACK;
niimurasyou 9:ec30ae33cc9e 269 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 270 motor[b].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 271 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 272 }else if(conrx > 8){
niimurasyou 9:ec30ae33cc9e 273 motor[a].dir = FOR;
niimurasyou 9:ec30ae33cc9e 274 motor[b].dir = FOR;
niimurasyou 9:ec30ae33cc9e 275 motor[c].dir = FOR;
niimurasyou 9:ec30ae33cc9e 276 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 277 motor[b].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 278 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 279 }else{
niimurasyou 9:ec30ae33cc9e 280 motor[a].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 281 motor[b].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 282 motor[c].dir = BRAKE;
niimurasyou 9:ec30ae33cc9e 283 motor[a].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 284 motor[b].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 285 motor[c].pwm = 100.0;
niimurasyou 9:ec30ae33cc9e 286 }
niimurasyou 11:88f17bc0724f 287 }
niimurasyou 11:88f17bc0724f 288
niimurasyou 11:88f17bc0724f 289 ////////////課題1////////////
niimurasyou 11:88f17bc0724f 290 if(controller->Button.X){
niimurasyou 11:88f17bc0724f 291 if(Switch::checkPushed(ARMlim)){
niimurasyou 11:88f17bc0724f 292 motor[d].dir = BRAKE;
niimurasyou 11:88f17bc0724f 293 motor[d].pwm = 100;
niimurasyou 11:88f17bc0724f 294 }else{
niimurasyou 11:88f17bc0724f 295 motor[d].dir = FOR;
niimurasyou 11:88f17bc0724f 296 motor[d].pwm = 100;
niimurasyou 11:88f17bc0724f 297 }
niimurasyou 11:88f17bc0724f 298 }else if(controller->Button.Y){
niimurasyou 11:88f17bc0724f 299 motor[d].dir = BACK;
niimurasyou 11:88f17bc0724f 300 motor[d].pwm = 100;
niimurasyou 11:88f17bc0724f 301 }else{
niimurasyou 11:88f17bc0724f 302 motor[d].dir = BRAKE;
niimurasyou 11:88f17bc0724f 303 motor[d].pwm = 100;
niimurasyou 11:88f17bc0724f 304 }
niimurasyou 11:88f17bc0724f 305 if(controller->Button.A) {
niimurasyou 11:88f17bc0724f 306 AirOut(Air0,1);
niimurasyou 11:88f17bc0724f 307 } else if(controller->Button.B) {
niimurasyou 11:88f17bc0724f 308 AirOut(Air0,0);
niimurasyou 11:88f17bc0724f 309 }
niimurasyou 11:88f17bc0724f 310 //////////////課題2/////////////////////
niimurasyou 11:88f17bc0724f 311 // if((controller->Button.ZL)&&(mode==0)) {
niimurasyou 11:88f17bc0724f 312 // Airtime.start();
niimurasyou 11:88f17bc0724f 313 // AirOut(Air1,0);
niimurasyou 11:88f17bc0724f 314 // }
niimurasyou 11:88f17bc0724f 315 // if((s>1)&&(s<3)) {
niimurasyou 11:88f17bc0724f 316 // AirOut(Air1,1);
niimurasyou 11:88f17bc0724f 317 // }else if(s>=3){
niimurasyou 11:88f17bc0724f 318 // Airtime.stop();
niimurasyou 11:88f17bc0724f 319 // Airtime.reset();
niimurasyou 11:88f17bc0724f 320 // mode=1;
niimurasyou 11:88f17bc0724f 321 // }
niimurasyou 11:88f17bc0724f 322 // if((mode==2)||((controller->Button.ZR)&&(mode==1))) {
niimurasyou 11:88f17bc0724f 323 // motor[4].dir=FOR;
niimurasyou 11:88f17bc0724f 324 // motor[4].pwm=10;
niimurasyou 11:88f17bc0724f 325 // }
niimurasyou 11:88f17bc0724f 326 // if(!(Switch::checkPushed(lim))&&(mode==1)){
niimurasyou 11:88f17bc0724f 327 // mode=2;
niimurasyou 11:88f17bc0724f 328 // }
niimurasyou 11:88f17bc0724f 329 // if((Switch::checkPushed(lim))&&(mode==2)){
niimurasyou 11:88f17bc0724f 330 // motor[4].dir=BRAKE;
niimurasyou 11:88f17bc0724f 331 // motor[4].pwm=100;
niimurasyou 11:88f17bc0724f 332 // mode=0;
niimurasyou 11:88f17bc0724f 333 // }
niimurasyou 9:ec30ae33cc9e 334 //
niimurasyou 11:88f17bc0724f 335 // if (controller->Button.ZL)
niimurasyou 11:88f17bc0724f 336 // AiOut(Air1,0);
niimurasyou 11:88f17bc0724f 337
niimurasyou 11:88f17bc0724f 338 if(controller->Button.ZL){
niimurasyou 11:88f17bc0724f 339 AirOut(Air1,1)
niimurasyou 11:88f17bc0724f 340 AirOut(Air1.0)
niimurasyou 11:88f17bc0724f 341 motor[4].dir = FOR;
niimurasyou 11:88f17bc0724f 342 motor[4].pwm = 100.0;
niimurasyou 11:88f17bc0724f 343 if(Switch::checkPushed(lim)){
niimurasyou 11:88f17bc0724f 344 motor.
niimurasyou 11:88f17bc0724f 345 }
niimurasyou 9:ec30ae33cc9e 346
niimurasyou 9:ec30ae33cc9e 347 //↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
niimurasyou 9:ec30ae33cc9e 348 //___________________________
t_yamamoto 0:562021ed1ba9 349
t_yamamoto 0:562021ed1ba9 350
niimurasyou 9:ec30ae33cc9e 351
t_yamamoto 0:562021ed1ba9 352 MOTOR::Motor::Update(motor);
t_yamamoto 0:562021ed1ba9 353 }
niimurasyou 9:ec30ae33cc9e 354 }