2018a/Member 目次
#define go OnFwd(OUT_AC);Off(OUT_AC); #define turn_right OnFwd(OUT_A);Off(OUT_C); #define turn_left OnFwd(OUT_C);Off(OUT_A); #define turn_r OnFwd(OUT_A);OnRev(OUT_C); #define turn_l OnFwd(OUT_C);OnRev(OUT_A); #define black 30 #define white 50 #define bw 35 #define wb 47 #define grey 43 #define set_power_A SetPower(OUT_B,3); #define wait Wait(100);
sub trace_1() //左トレース { int n=0; while(n<=3) { if(SENSOR_2>=white){ turn_r; n=0; }else if(SENSOR_2>=wb){ turn_right; n=0; }else if(SENSOR_2>=grey){ go; n=0; }else if(SENSOR_2>=bw){ turn_left; n=0; }else{ turn_l; n++; } } }
sub trace_2() // 左トレース(内側急カーブ) { int x=0; while(x<=20) { if(SENSOR_2>=white){ turn_r; x=0; }else if(SENSOR_2>=wb){ turn_right; x=0; }else if(SENSOR_2>=grey){ go; x=0; }else if(SENSOR_2>=bw){ turn_left; x=0; }else{ turn_l; x++; } } }
sub trace_3() //右トレース1 { int y=0; while(y<=1) { if(SENSOR_2>=white){ turn_l; y=0; }else if(SENSOR_2>=wb){ turn_left; y=0; }else if(SENSOR_2>=grey){ go; y=0; }else if(SENSOR_2>=bw){ turn_right; y=0; }else{ turn_r; y++; } } }
sub trace_4() //右トレース2 { int z=0; while(z<=2) { if(SENSOR_2>=white){ turn_l; z=0; }else if(SENSOR_2>=wb){ turn_left; z=0; }else if(SENSOR_2>=grey){ go; z=0; }else if(SENSOR_2>=bw){ turn_right; z=0; }else{ turn_r; z++; } } }
task main () { SetSensor(SENSOR_2,SENSOR_LIGHT); trace_1(); Off(OUT_AC); wait; //C turn_r; Wait(10); OnFwd(OUT_AC); wait; trace_1(); Off(OUT_AC); //D wait; OnFwd(OUT_AC); Wait(20); Off(OUT_AC); wait; set_power_A; OnRev(OUT_B); //アームdown Wait(30); Off(OUT_B); OnRev(OUT_AC); Wait(20); Off(OUT_AC); trace_1(); Off(OUT_AC); //G wait; trace_2(); Off(OUT_AC); wait; turn_l; Wait(10); trace_1(); Off(OUT_AC); //H wait; turn_r; Wait(95); trace_3(); Off(OUT_AC); //I wait; trace_4(); Off(OUT_AC); go; Wait(30); trace_4(); Off(OUT_AC); go; Wait(30); trace_4(); Off(OUT_AC); //J wait; turn_l; Wait(95); set_power_A; OnFwd(OUT_B); //アームup Wait(30); Off(OUT_B); turn_r; wait; Off(OUT_AC); trace_1(); Off(OUT_AC); //B wait; trace_1(); Off(OUT_AC); }