#define BLACK_high 37
#define BLACK_low 40
#define WHITE_low 43
#define WHITE_high 47
#define TURNSENSOR 37
#define turn_left_senkai OnRev(OUT_A); OnFwd(OUT_C);
#define turn_left_kaiten Off(OUT_A); OnFwd(OUT_C);
#define turn_right_kaiten OnFwd(OUT_A); Off(OUT_C);
#define turn_right_senkai OnFwd(OUT_A); OnRev(OUT_C);
#define go_fwd OnFwd(OUT_AC);
#define short_break Off(OUT_AC); Wait(100);
#define cross_time 100
#define cross_line turn_right_senkai Wait(STEP*nMAX); go_fwd Wait(cross_time)
#define back_turn_left_kaiten Off(OUT_A); OnRev(OUT_C);
#define back_turn_right_kaiten OnRev(OUT_A); Off(OUT_C);
#define go_rev OnRev(OUT_AC);
#define SHOTBALL OnFwd(OUT_B); Wait(500);
#define CATCHBALL OnRev(OUT_B); Wait(500);
#define TURNSTEP 1
#define time1 500
#define time2 300
#define time3 600
#define mess1
#define mess2
#define mess3
#define nMAX 5
#define STEP 1


task main(){
SetSensor(SENSOR_1,SENSOR_LIGHT);
SetSensor(SENSOR_2,SENSOR_LIGHT);
int nCross=0;
int nOnline=0;
ClearTimer(0);
  while(nCross <= 2){
  while(nOnline < nMAX){
    if(SENSOR_1 < BLACK_high){
	turn_left_senkai;
	nOnline++;
    } else if(SENSOR_2 < BLACK_low){
	turn_left_kaiten;
    } else if(SENSOR_2 < WHITE_low){
	go_fwd;
    } else if(SENSOR_2 < WHITE_high){
	turn_right_kaiten;
    } else {
	turn_right_senkai;
     } 
   }
  nOnline == 0;
  nCross ++;
  short_break;
  cross_line;
  }
  OnRev(OUT_A);
  OnFwd(OUT_C);
  Wait(100);    //ボールに向く  
  CATCHBALL;
  OnFwd(OUT_AC);
  Wait(200);   //ボールを取る
  until(SENSOR_1 < BLACK_low){
    turn_left_kaiten;
  }                //コースに戻る
  while(nCross <= 1){
    if(SENSOR_1 < BLACK_high){
	turn_left_senkai;
	nOnline ++;
    } else if(SENSOR_2 < BLACK_low){
	turn_left_kaiten;
    } else if(SENSOR_2 < WHITE_low){
	go_fwd;
    } else if(SENSOR_2 < WHITE_high){
	turn_right_kaiten;
    } else {
	turn_right_senkai;
     } 
   }
}

トップ   編集 凍結 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS
Last-modified: 2013-08-01 (木) 17:24:09