motor(lpc1768)

Dependencies:   mbed PololuLedStrip

Committer:
hamaken1018
Date:
Mon Jan 25 07:20:38 2021 +0000
Revision:
0:3b06c3283e31
a;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hamaken1018 0:3b06c3283e31 1 #include "mbed.h"
hamaken1018 0:3b06c3283e31 2 #include "PololuLedStrip.h"
hamaken1018 0:3b06c3283e31 3 #include <math.h>
hamaken1018 0:3b06c3283e31 4
hamaken1018 0:3b06c3283e31 5 Serial Xbee(P0_10,P0_11,19200); //TX,RX,クロックレート
hamaken1018 0:3b06c3283e31 6 Serial Xbee2(P0_0,P0_1,19200); //LEDに送信
hamaken1018 0:3b06c3283e31 7 Serial pc(USBTX,USBRX); //pc(USBTX,USBRX)
hamaken1018 0:3b06c3283e31 8 Ticker ticker;
hamaken1018 0:3b06c3283e31 9 unsigned char RX_data;
hamaken1018 0:3b06c3283e31 10
hamaken1018 0:3b06c3283e31 11 #define DIGITS 8
hamaken1018 0:3b06c3283e31 12 #define ledsize 65
hamaken1018 0:3b06c3283e31 13 //円周率
hamaken1018 0:3b06c3283e31 14 #define PI 3.14159265358979
hamaken1018 0:3b06c3283e31 15 //モータードライバ
hamaken1018 0:3b06c3283e31 16 #define M1 0x01
hamaken1018 0:3b06c3283e31 17
hamaken1018 0:3b06c3283e31 18 //モータードライバへの命令
hamaken1018 0:3b06c3283e31 19 #define STOP 0
hamaken1018 0:3b06c3283e31 20 #define CW 1
hamaken1018 0:3b06c3283e31 21 #define CCW -1
hamaken1018 0:3b06c3283e31 22 #define bSTOP 10
hamaken1018 0:3b06c3283e31 23 #define bCW 11
hamaken1018 0:3b06c3283e31 24 #define bCCW -11
hamaken1018 0:3b06c3283e31 25
hamaken1018 0:3b06c3283e31 26 #define sCW 21
hamaken1018 0:3b06c3283e31 27 #define sCCW -21
hamaken1018 0:3b06c3283e31 28 #define sSTOP 20
hamaken1018 0:3b06c3283e31 29 #define shCW 31
hamaken1018 0:3b06c3283e31 30 #define shCCW -31
hamaken1018 0:3b06c3283e31 31
hamaken1018 0:3b06c3283e31 32 #define lCW 51
hamaken1018 0:3b06c3283e31 33 #define lCCW -51
hamaken1018 0:3b06c3283e31 34 #define lSTOP 50
hamaken1018 0:3b06c3283e31 35 #define lsCW 61
hamaken1018 0:3b06c3283e31 36 #define lsCCW -61
hamaken1018 0:3b06c3283e31 37 #define lsSTOP 60
hamaken1018 0:3b06c3283e31 38
hamaken1018 0:3b06c3283e31 39 #define rON 41
hamaken1018 0:3b06c3283e31 40 #define rOFF -41
hamaken1018 0:3b06c3283e31 41
hamaken1018 0:3b06c3283e31 42 DigitalOut led1(LED1);
hamaken1018 0:3b06c3283e31 43 DigitalOut led2(LED2);
hamaken1018 0:3b06c3283e31 44 DigitalOut led3(LED3);
hamaken1018 0:3b06c3283e31 45 DigitalOut ledx(LED4);
hamaken1018 0:3b06c3283e31 46 I2C md_i2c_tx(P0_27, P0_28);
hamaken1018 0:3b06c3283e31 47
hamaken1018 0:3b06c3283e31 48 void cv2bin( unsigned char n ) {
hamaken1018 0:3b06c3283e31 49 int i;
hamaken1018 0:3b06c3283e31 50
hamaken1018 0:3b06c3283e31 51 for( i = DIGITS-1; i >= 0; i-- ) {
hamaken1018 0:3b06c3283e31 52 printf( "%d", ( n >> i ) & 1 );
hamaken1018 0:3b06c3283e31 53 }
hamaken1018 0:3b06c3283e31 54 printf( "\n" );
hamaken1018 0:3b06c3283e31 55 }
hamaken1018 0:3b06c3283e31 56
hamaken1018 0:3b06c3283e31 57 //i2c通信
hamaken1018 0:3b06c3283e31 58 void md_setoutput(unsigned char address, int rotate, int duty) {
hamaken1018 0:3b06c3283e31 59 char val;
hamaken1018 0:3b06c3283e31 60 char data[2];
hamaken1018 0:3b06c3283e31 61 /* H30新型:処理最適化 */
hamaken1018 0:3b06c3283e31 62 switch (rotate) {
hamaken1018 0:3b06c3283e31 63 case CW: data[0] = 'F'; break;// 電圧比例制御モード(PWMがLの区間はフリー)
hamaken1018 0:3b06c3283e31 64 case CCW: data[0] = 'R'; break;
hamaken1018 0:3b06c3283e31 65 case STOP: data[0] = 'S'; break;
hamaken1018 0:3b06c3283e31 66
hamaken1018 0:3b06c3283e31 67 case bCW: data[0] = 'f'; break; // 電圧比例制御モード(PWMがLの区間はブレーキ) //ブレーキ停止は機体に負荷がかかるため使用禁止
hamaken1018 0:3b06c3283e31 68 case bCCW: data[0] = 'r'; break;
hamaken1018 0:3b06c3283e31 69 case bSTOP: data[0] = 's'; break;
hamaken1018 0:3b06c3283e31 70
hamaken1018 0:3b06c3283e31 71 case sCW: data[0] = 'A'; break; // 速度比例制御モード
hamaken1018 0:3b06c3283e31 72 case sCCW: data[0] = 'B'; break;
hamaken1018 0:3b06c3283e31 73 case sSTOP: data[0] = 'T'; break;
hamaken1018 0:3b06c3283e31 74
hamaken1018 0:3b06c3283e31 75 case shCW: data[0] = 'a'; break; // 速度比例制御モード(命令パケット最上位ビットに指令値9ビット目を入れることで分解能2倍)
hamaken1018 0:3b06c3283e31 76 case shCCW: data[0] = 'b'; break;
hamaken1018 0:3b06c3283e31 77
hamaken1018 0:3b06c3283e31 78 case lCW: data[0] = 'L'; break; // 通常LAP
hamaken1018 0:3b06c3283e31 79 case lCCW: data[0] = 'M'; break;
hamaken1018 0:3b06c3283e31 80 case lSTOP: data[0] = 'N'; break;
hamaken1018 0:3b06c3283e31 81 case lsCW: data[0] = 'l'; break; // 速調LAP
hamaken1018 0:3b06c3283e31 82 case lsCCW: data[0] = 'm'; break;
hamaken1018 0:3b06c3283e31 83 case lsSTOP: data[0] = 'n'; break;
hamaken1018 0:3b06c3283e31 84
hamaken1018 0:3b06c3283e31 85 case rON: data[0] = 'P'; break; //リレー駆動モード
hamaken1018 0:3b06c3283e31 86 case rOFF: data[0] = 'p'; break;
hamaken1018 0:3b06c3283e31 87 }
hamaken1018 0:3b06c3283e31 88
hamaken1018 0:3b06c3283e31 89 data[1] = duty & 0xFF;
hamaken1018 0:3b06c3283e31 90
hamaken1018 0:3b06c3283e31 91 val = md_i2c_tx.write(address << 1, data, 2); //duty送信
hamaken1018 0:3b06c3283e31 92 }
hamaken1018 0:3b06c3283e31 93 #define LED_COUNT 66 //LEDの数
hamaken1018 0:3b06c3283e31 94 PololuLedStrip ledStrip1(P2_13);
hamaken1018 0:3b06c3283e31 95 rgb_color colors[LED_COUNT];
hamaken1018 0:3b06c3283e31 96 int cnt = 0;
hamaken1018 0:3b06c3283e31 97 int EMS = 0;
hamaken1018 0:3b06c3283e31 98 int con = 0;
hamaken1018 0:3b06c3283e31 99 int motorOn = 0;
hamaken1018 0:3b06c3283e31 100 int LEDDATA = 1;
hamaken1018 0:3b06c3283e31 101
hamaken1018 0:3b06c3283e31 102 void Xbee_RX(){
hamaken1018 0:3b06c3283e31 103
hamaken1018 0:3b06c3283e31 104 RX_data = Xbee.getc(); //Xbeeから送られてきた文字を代入
hamaken1018 0:3b06c3283e31 105 pc.putc(RX_data); //値をpcに表示
hamaken1018 0:3b06c3283e31 106
hamaken1018 0:3b06c3283e31 107 //非常停止 EMSが1で入る
hamaken1018 0:3b06c3283e31 108 if (cnt == 0 && RX_data == 'S'){
hamaken1018 0:3b06c3283e31 109 cnt++;
hamaken1018 0:3b06c3283e31 110 }else if (cnt == 1 && RX_data == 'T'){
hamaken1018 0:3b06c3283e31 111 cnt++;
hamaken1018 0:3b06c3283e31 112 }else if (cnt == 2 && RX_data == 'O'){
hamaken1018 0:3b06c3283e31 113 cnt++;
hamaken1018 0:3b06c3283e31 114 }else if (cnt == 3 && RX_data == 'P'){
hamaken1018 0:3b06c3283e31 115 cnt = 0;
hamaken1018 0:3b06c3283e31 116 EMS = 1;
hamaken1018 0:3b06c3283e31 117 led1 = 1;
hamaken1018 0:3b06c3283e31 118 }else if (RX_data == 'L'){
hamaken1018 0:3b06c3283e31 119 cnt = 0;
hamaken1018 0:3b06c3283e31 120 EMS = 0;
hamaken1018 0:3b06c3283e31 121 led1 = 0;
hamaken1018 0:3b06c3283e31 122 }
hamaken1018 0:3b06c3283e31 123 }
hamaken1018 0:3b06c3283e31 124
hamaken1018 0:3b06c3283e31 125 rgb_color COLOR(float H,int n){
hamaken1018 0:3b06c3283e31 126
hamaken1018 0:3b06c3283e31 127 float r = 0, g = 0, b = 0;
hamaken1018 0:3b06c3283e31 128 H = 100; //光の強さ
hamaken1018 0:3b06c3283e31 129 switch (n){
hamaken1018 0:3b06c3283e31 130 case 1:r = H; g = 0; b = 0; break; //赤
hamaken1018 0:3b06c3283e31 131 case 2:r = 0; g = H; b = 0; break; //緑
hamaken1018 0:3b06c3283e31 132 case 3:r = 0; g = 0; b = H; break; //青
hamaken1018 0:3b06c3283e31 133 case 4:r = H; g = H; b = 0; break; //黄色
hamaken1018 0:3b06c3283e31 134 case 5:r = 0; g = H; b = H; break; //水色
hamaken1018 0:3b06c3283e31 135 case 6:r = H; g = 0; b = H; break; //紫
hamaken1018 0:3b06c3283e31 136 case 7:r = H; g = H; b = H; break; //白
hamaken1018 0:3b06c3283e31 137 case 8:r = H; g = H * 0.5; b = 0; break; //オレンジ
hamaken1018 0:3b06c3283e31 138 }
hamaken1018 0:3b06c3283e31 139 return (rgb_color){r,g,b};
hamaken1018 0:3b06c3283e31 140 }
hamaken1018 0:3b06c3283e31 141
hamaken1018 0:3b06c3283e31 142 //フォトリフレクタ
hamaken1018 0:3b06c3283e31 143 double fot;
hamaken1018 0:3b06c3283e31 144 int h = 0;
hamaken1018 0:3b06c3283e31 145 int b = 0;
hamaken1018 0:3b06c3283e31 146 //↓LED色
hamaken1018 0:3b06c3283e31 147 int R = 1;
hamaken1018 0:3b06c3283e31 148 int G = 2;
hamaken1018 0:3b06c3283e31 149 int B = 3;
hamaken1018 0:3b06c3283e31 150 int Y = 4;
hamaken1018 0:3b06c3283e31 151 int L = 5;
hamaken1018 0:3b06c3283e31 152 int P = 6;
hamaken1018 0:3b06c3283e31 153 int W = 7;
hamaken1018 0:3b06c3283e31 154 int O = 8;
hamaken1018 0:3b06c3283e31 155
hamaken1018 0:3b06c3283e31 156 void ledsw(){
hamaken1018 0:3b06c3283e31 157 h++;
hamaken1018 0:3b06c3283e31 158 }
hamaken1018 0:3b06c3283e31 159
hamaken1018 0:3b06c3283e31 160 int main() {
hamaken1018 0:3b06c3283e31 161 wait_ms(10);
hamaken1018 0:3b06c3283e31 162 led1 = 1;
hamaken1018 0:3b06c3283e31 163 led2 = 0;
hamaken1018 0:3b06c3283e31 164 led3 = 0;
hamaken1018 0:3b06c3283e31 165 ledx = 1;
hamaken1018 0:3b06c3283e31 166 Xbee.attach(&Xbee_RX, Serial::RxIrq); //割り込み
hamaken1018 0:3b06c3283e31 167 pc.baud(115200); //pcクロックレート
hamaken1018 0:3b06c3283e31 168 md_i2c_tx.frequency(20000000UL/(16 + 2 * 2 * 16));//I2C通信
hamaken1018 0:3b06c3283e31 169
hamaken1018 0:3b06c3283e31 170 while(1){
hamaken1018 0:3b06c3283e31 171 //機構用モータ
hamaken1018 0:3b06c3283e31 172 if(EMS){
hamaken1018 0:3b06c3283e31 173 md_setoutput(M1,STOP,0);
hamaken1018 0:3b06c3283e31 174 }else if(EMS == 0){
hamaken1018 0:3b06c3283e31 175 md_setoutput(M1,CW,255);
hamaken1018 0:3b06c3283e31 176 }
hamaken1018 0:3b06c3283e31 177
hamaken1018 0:3b06c3283e31 178 //***************打ち上げ処理******************//
hamaken1018 0:3b06c3283e31 179 if(RX_data == 'A' && con == 0){
hamaken1018 0:3b06c3283e31 180 con = 1;
hamaken1018 0:3b06c3283e31 181 h = 0;
hamaken1018 0:3b06c3283e31 182 ticker.attach(ledsw,0.05);
hamaken1018 0:3b06c3283e31 183 }else if(RX_data == 'B' && con == 1){
hamaken1018 0:3b06c3283e31 184 con = 2;
hamaken1018 0:3b06c3283e31 185 h = 0;
hamaken1018 0:3b06c3283e31 186 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 187 }else if(RX_data == 'C' && con == 2){
hamaken1018 0:3b06c3283e31 188 con = 3;
hamaken1018 0:3b06c3283e31 189 h = 0;
hamaken1018 0:3b06c3283e31 190 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 191 }else if(RX_data == 'D' && con == 3){
hamaken1018 0:3b06c3283e31 192 con = 4;
hamaken1018 0:3b06c3283e31 193 h = 0;
hamaken1018 0:3b06c3283e31 194 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 195 }else if(RX_data == 'E' && con == 4){
hamaken1018 0:3b06c3283e31 196 con = 5;
hamaken1018 0:3b06c3283e31 197 h = 0;
hamaken1018 0:3b06c3283e31 198 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 199 }else if(RX_data == 'A' && con == 5){
hamaken1018 0:3b06c3283e31 200 con = 6;
hamaken1018 0:3b06c3283e31 201 h = 0;
hamaken1018 0:3b06c3283e31 202 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 203 }else if(RX_data == 'B' && con == 6){
hamaken1018 0:3b06c3283e31 204 con = 7;
hamaken1018 0:3b06c3283e31 205 h = 0;
hamaken1018 0:3b06c3283e31 206 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 207 }else if(RX_data == 'C' && con == 7){
hamaken1018 0:3b06c3283e31 208 con = 8;
hamaken1018 0:3b06c3283e31 209 h = 0;
hamaken1018 0:3b06c3283e31 210 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 211 }else if(RX_data == 'D' && con == 8){
hamaken1018 0:3b06c3283e31 212 con = 9;
hamaken1018 0:3b06c3283e31 213 h = 0;
hamaken1018 0:3b06c3283e31 214 ticker.attach(ledsw,0.2);
hamaken1018 0:3b06c3283e31 215 }
hamaken1018 0:3b06c3283e31 216
hamaken1018 0:3b06c3283e31 217 if(con == 1){
hamaken1018 0:3b06c3283e31 218 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 219 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 220 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 221 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 222 }
hamaken1018 0:3b06c3283e31 223
hamaken1018 0:3b06c3283e31 224 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 225 colors[ledsize - h] = COLOR(phase, B);
hamaken1018 0:3b06c3283e31 226 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 227
hamaken1018 0:3b06c3283e31 228 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 229 ticker.detach();
hamaken1018 0:3b06c3283e31 230 Xbee2.putc('A');
hamaken1018 0:3b06c3283e31 231 }
hamaken1018 0:3b06c3283e31 232 }
hamaken1018 0:3b06c3283e31 233 }
hamaken1018 0:3b06c3283e31 234
hamaken1018 0:3b06c3283e31 235 if(con == 2){
hamaken1018 0:3b06c3283e31 236 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 237 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 238 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 239 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 240 }
hamaken1018 0:3b06c3283e31 241
hamaken1018 0:3b06c3283e31 242 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 243 colors[ledsize - h] = COLOR(phase, G);
hamaken1018 0:3b06c3283e31 244 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 245
hamaken1018 0:3b06c3283e31 246 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 247 ticker.detach();
hamaken1018 0:3b06c3283e31 248 Xbee2.putc('B');
hamaken1018 0:3b06c3283e31 249 }
hamaken1018 0:3b06c3283e31 250 }
hamaken1018 0:3b06c3283e31 251 }
hamaken1018 0:3b06c3283e31 252
hamaken1018 0:3b06c3283e31 253 if(con == 3){
hamaken1018 0:3b06c3283e31 254 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 255 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 256 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 257 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 258 }
hamaken1018 0:3b06c3283e31 259
hamaken1018 0:3b06c3283e31 260 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 261 colors[ledsize - h] = COLOR(phase, R);
hamaken1018 0:3b06c3283e31 262 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 263
hamaken1018 0:3b06c3283e31 264 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 265 ticker.detach();
hamaken1018 0:3b06c3283e31 266 Xbee2.putc('C');
hamaken1018 0:3b06c3283e31 267 }
hamaken1018 0:3b06c3283e31 268 }
hamaken1018 0:3b06c3283e31 269 }
hamaken1018 0:3b06c3283e31 270
hamaken1018 0:3b06c3283e31 271 if(con == 4){
hamaken1018 0:3b06c3283e31 272 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 273 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 274 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 275 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 276 }
hamaken1018 0:3b06c3283e31 277
hamaken1018 0:3b06c3283e31 278 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 279 colors[ledsize - h] = COLOR(phase, O);
hamaken1018 0:3b06c3283e31 280 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 281
hamaken1018 0:3b06c3283e31 282 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 283 ticker.detach();
hamaken1018 0:3b06c3283e31 284 Xbee2.putc('D');
hamaken1018 0:3b06c3283e31 285 }
hamaken1018 0:3b06c3283e31 286 }
hamaken1018 0:3b06c3283e31 287 }
hamaken1018 0:3b06c3283e31 288
hamaken1018 0:3b06c3283e31 289 if(con == 5){
hamaken1018 0:3b06c3283e31 290 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 291 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 292 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 293 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 294 }
hamaken1018 0:3b06c3283e31 295
hamaken1018 0:3b06c3283e31 296 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 297 colors[ledsize - h] = COLOR(phase, P);
hamaken1018 0:3b06c3283e31 298 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 299
hamaken1018 0:3b06c3283e31 300 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 301 ticker.detach();
hamaken1018 0:3b06c3283e31 302 Xbee2.putc('E');
hamaken1018 0:3b06c3283e31 303 }
hamaken1018 0:3b06c3283e31 304 }
hamaken1018 0:3b06c3283e31 305 }
hamaken1018 0:3b06c3283e31 306
hamaken1018 0:3b06c3283e31 307 if(con == 6){
hamaken1018 0:3b06c3283e31 308 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 309 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 310 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 311 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 312 }
hamaken1018 0:3b06c3283e31 313
hamaken1018 0:3b06c3283e31 314 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 315 colors[ledsize - h] = COLOR(phase, P);
hamaken1018 0:3b06c3283e31 316 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 317
hamaken1018 0:3b06c3283e31 318 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 319 ticker.detach();
hamaken1018 0:3b06c3283e31 320 Xbee2.putc('F');
hamaken1018 0:3b06c3283e31 321 }
hamaken1018 0:3b06c3283e31 322 }
hamaken1018 0:3b06c3283e31 323 }
hamaken1018 0:3b06c3283e31 324
hamaken1018 0:3b06c3283e31 325 if(con == 7){
hamaken1018 0:3b06c3283e31 326 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 327 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 328 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 329 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 330 }
hamaken1018 0:3b06c3283e31 331
hamaken1018 0:3b06c3283e31 332 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 333 colors[ledsize - h] = COLOR(phase, P);
hamaken1018 0:3b06c3283e31 334 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 335
hamaken1018 0:3b06c3283e31 336
hamaken1018 0:3b06c3283e31 337 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 338 ticker.detach();
hamaken1018 0:3b06c3283e31 339 Xbee2.putc('G');
hamaken1018 0:3b06c3283e31 340 }
hamaken1018 0:3b06c3283e31 341 }
hamaken1018 0:3b06c3283e31 342 }
hamaken1018 0:3b06c3283e31 343
hamaken1018 0:3b06c3283e31 344 if(con == 8){
hamaken1018 0:3b06c3283e31 345 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 346 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 347 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 348 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 349 }
hamaken1018 0:3b06c3283e31 350
hamaken1018 0:3b06c3283e31 351 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 352 colors[ledsize - h] = COLOR(phase, P);
hamaken1018 0:3b06c3283e31 353 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 354
hamaken1018 0:3b06c3283e31 355
hamaken1018 0:3b06c3283e31 356 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 357 ticker.detach();
hamaken1018 0:3b06c3283e31 358 Xbee2.putc('H');
hamaken1018 0:3b06c3283e31 359 }
hamaken1018 0:3b06c3283e31 360 }
hamaken1018 0:3b06c3283e31 361 }
hamaken1018 0:3b06c3283e31 362
hamaken1018 0:3b06c3283e31 363 if(con == 9){
hamaken1018 0:3b06c3283e31 364 if(h < LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 365 for(int k = 0; k < LED_COUNT; k++){
hamaken1018 0:3b06c3283e31 366 uint8_t phase =(k << 1);
hamaken1018 0:3b06c3283e31 367 colors[k] = COLOR(phase, 0);
hamaken1018 0:3b06c3283e31 368 }
hamaken1018 0:3b06c3283e31 369
hamaken1018 0:3b06c3283e31 370 uint8_t phase =(h << 1);
hamaken1018 0:3b06c3283e31 371 colors[ledsize - h] = COLOR(phase, P);
hamaken1018 0:3b06c3283e31 372 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 373
hamaken1018 0:3b06c3283e31 374 if(h == LED_COUNT + 1){
hamaken1018 0:3b06c3283e31 375 ticker.detach();
hamaken1018 0:3b06c3283e31 376 Xbee2.putc('I');
hamaken1018 0:3b06c3283e31 377 con = 0;
hamaken1018 0:3b06c3283e31 378 }
hamaken1018 0:3b06c3283e31 379 }
hamaken1018 0:3b06c3283e31 380 }
hamaken1018 0:3b06c3283e31 381
hamaken1018 0:3b06c3283e31 382 ledStrip1.write(colors, LED_COUNT);
hamaken1018 0:3b06c3283e31 383 }
hamaken1018 0:3b06c3283e31 384 }