[[2013a/Member]] *サッカーロボの解説 [#ma809a44] #define off Off(OUT_BC); #define TURN_TIME 500 //1/4回転の時間 #define BLACK 31 #define WHITE 62 #define SPEED 100 #define go OnFwd(OUT_BC,30); #define left OnFwd(OUT_B,30);Off(OUT_C); #define right OnFwd(OUT_C,30);Off(OUT_B); #define THRESHOLD 46 #define lleft OnFwd(OUT_B,30);OnRev(OUT_C,30); #define rright OnFwd(OUT_C,30);OnRev(OUT_B,30); #define fire OnRev(OUT_A,55); #define catch OnFwd(OUT_A,40); #define back OnRev(OUT_BC,30); #define off1 Off(OUT_BC); #define off2 Off(OUT_A); #define CONN 1 task main() {//1 SetSensorLight(S1);//光センサー定義 int n=0;//変数1 int m=0;//変数2 int msg; while(n<600)//球をとるまでのプログラム {//2 if (SENSOR_1 < 35){left;n++; } else {//3 if(SENSOR_1 < 42){lleft} else if (SENSOR_1 < 50){go} else if (SENSOR_1 < 56){right} else {rright} n=0; }//3 }//2 back Wait(1250); right Wait(980);//球の方向へ go Wait(500);//進む catch Wait(500);//球を抑える Off(OUT_A); rright Wait(1500);//元の方向へ go Wait(2450); while(SENSOR_1 > 50){left} long t0 = CurrentTick();//時間指定 while(CurrentTick()-t0 <= 4850)//球を排出するまでのプログラム {//5 if (SENSOR_1 < 37){left} else {//6 if(SENSOR_1 < 45){lleft} else if (SENSOR_1 < 50){go} else if (SENSOR_1 < 56){right} else {rright} }//6 }//5 lleft//球排出 Wait(1040); Off(OUT_BC); Wait(2000); SendRemoteNumber(CONN,MAILBOX1,11); fire Wait(1200); Off(OUT_A); rright Wait(400); while(SENSOR_1 > 50){rright} go//次の地点へ Wait(2050); lleft//受け取る体勢 Wait(1040); Off(OUT_BC); Wait(5000); SendRemoteNumber(CONN,MAILBOX1,12); Wait(3000); catch Wait(350); Off(OUT_A); while(SENSOR_1 > 50){rright} long t3 = CurrentTick(); while(CurrentTick()-t3 <= 2400)//球を排出するまでのプログラム {//5 if (SENSOR_1 < 37){left} else {//6 if(SENSOR_1 < 45){lleft} else if (SENSOR_1 < 50){go} else if (SENSOR_1 < 56){right} else {rright} }//6 }//5 lleft//球排出 Wait(1040); Off(OUT_BC); Wait(5000); SendRemoteNumber(CONN,MAILBOX1,13); fire Wait(1000);//1回目終了 Off(OUT_A); Wait(40000); SendRemoteNumber(CONN,MAILBOX1,13); Wait(800); catch Off(OUT_A); Wait(500); while(SENSOR_1 > 50){lleft} long t4 = CurrentTick(); while(CurrentTick()-t4 <= 1500)//球を排出するまでのプログラム {//5 if (SENSOR_1 < 37){left} else {//6 if(SENSOR_1 < 45){lleft} else if (SENSOR_1 < 50){go} else if (SENSOR_1 < 56){right} else {rright} }//6 }//5 rright Wait(1000); Off(OUT_BC); fire Wait(500); Off(OUT_A); while(SENSOR_1 > 50){lleft} long t5 = CurrentTick(); while(CurrentTick()-t5 <= 1500)//球を排出するまでのプログラム {//5 if (SENSOR_1 < 37){left} else {//6 if(SENSOR_1 < 45){lleft} else if (SENSOR_1 < 50){go} else if (SENSOR_1 < 56){right} else {rright} }//6 }//5 rright Wait(1000); Off(OUT_BC); catch Wait(500); Off(OUT_A); while(SENSOR_1 > 50){lleft} long t6 = CurrentTick(); while(CurrentTick()-t6 <= 5000)//ゴール用 {//7 if (SENSOR_1 < 35){left} else {//8 if(SENSOR_1 < 42){lleft} else if (SENSOR_1 < 50){go} else if (SENSOR_1 < 56){right} else {rright} }//8 }//7 fire Wait(1000); Off(OUT_A); }//1