[[2016b/Member]]
 #define go_go OnFwd(OUT_AC);
 #define turn_right OnFwd(OUT_C);Off(OUT_A);
 #define turn_left OnFwd(OUT_A);Off(OUT_C);
 #define kyu_turn_r OnFwd(OUT_C);OnRev(OUT_A);
 #define kyu_turn_l OnFwd(OUT_A);OnRev(OUT_C);
 #define right_cross  turn_right;Wait(110);
 #define straight_cross  kyu_turn_r;Wait(10);go_go;Wait(30);
 #define BLACK_a 44
 #define BLACK_b 48
 #define WHITE_a 52
 #define WHITE_b 58
 #define MOVE_TIME 18
 #define ball_get  go_go;Wait(20);Off(OUT_AC);OnFwd(OUT_B);Wait(20);Off(OUT_B);
 #define shoot OnRev(OUT_AC);     Wait(110);Off(OUT_AC);kyu_turn_l;Wait(80);Off(OUT_AC);Wait(40);kyu_turn_r;Wait(30);OnRev(OUT_B);Wait(20);Off(OUT_ABC);
 sub line_trace()
 {     ClearTimer(0);
       SetSensor(SENSOR_2,SENSOR_LIGHT);
       while(FastTimer(0)<=MOVE_TIME){ 
                     if(SENSOR_2<BLACK_a){
                          kyu_turn_l; 
                         }
                     else if(SENSOR_2<BLACK_b){
                       turn_left;
                       ClearTimer(0);
                        }
                   
                     else if(SENSOR_2<WHITE_a){
                       go_go;
                       ClearTimer(0);
                        }
                     else if(SENSOR_2<WHITE_b){
                          turn_right;
                          ClearTimer(0);
                        }
                      else {
                        kyu_turn_r;
                        ClearTimer(0);
                        }
       }
     Off(OUT_AC);
     Wait(100);
 } 




task main()
{
      line_trace();
      right_cross;
      line_trace();
      straight_cross;
      ball_get;
      line_trace();
      straight_cross;
      line_trace();
      right_cross;
      line_trace();
      straight_cross;
      line_trace();
      right_cross;
      line_trace();
      shoot;
}


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS