[[2013b/MemberOnly/進行状況]]

 #define THRESHOLD 45
 #define SPEED_H 50
 #define SPEED_L 25
 #define OnRL(speedR,speedL)\
  OnFwd(OUT_B,speedR);OnFwd(OUT_C,speedL);
 #define go OnRL(SPEED_H,SPEED_H);
 #define turn_L OnRL(-SPEED_L,SPEED_H);
 #define turn_l OnRL(-SPEED_L,SPEED_L);
 #define turn_R OnRL(SPEED_H,-SPEED_L);
 #define turn_r OnRL(SPEED_L,-SPEED_L);
 #define turn_u OnRL(-SPEED_L,SPEED_L);Wait(2000);
 #define tukamu OnFwd(OUT_A,SPEED_L);Wait(1000);
 #define hanasu OnRev(OUT_A,SPEED_L);Wait(1000);
 #define STEP 1

 task main()
 {
  Wait(2000);
  SetSensorLight(S1);
  SetSensorLowspeed(2);
  int n=0;
  int k=0;
  int f=0;
  long t0=CurrentTick(); 
 while(true){
     while(CurrentTick()-t0<=35000){
     if(SENSOR_1 < THRESHOLD -35){
       turn_l;
      }else if(SENSOR_1 < THRESHOLD -7){
       turn_L;
      }else if(SENSOR_1 < THRESHOLD +15){
       turn_R;
     
     }else{
      turn_r;
      }Wait(STEP);
     }


    while(CurrentTick()-t0<=45000){
      if(SENSOR_1 < THRESHOLD -35){
       turn_l;n++;
      }else if(SENSOR_1 < THRESHOLD -7){
       turn_L;n++;
      }else if(SENSOR_1 < THRESHOLD +15){
       turn_R;n=0;
     
     }else{
      turn_r;n=0;
      }
      if(n>=500){turn_r;Wait(100);n=0;k++;}
      if(k>=3){turn_l;Wait(300);go;Wait(300);k=0;}
      Wait(1);
      }
    
  while(CurrentTick()-t0<=50000){
      if(SENSOR_1 < THRESHOLD -35){
       turn_l;
      }else if(SENSOR_1 < THRESHOLD -7){
       turn_L;
      }else if(SENSOR_1 < THRESHOLD +15){
       turn_R;
     
     }else{
      turn_r;
      }
     Wait(STEP);
 	 }
  
     while(CurrentTick()-t0<=90000){
      if(SENSOR_1 < THRESHOLD -35){
       turn_l;n++;
      }else if(SENSOR_1 < THRESHOLD -7){
       turn_L;n++;
      }else if(SENSOR_1 < THRESHOLD +7){
       go;
      }else if(SENSOR_1 < THRESHOLD +15){
       turn_R;n=0;
    
     }else{
      turn_r;
      }
      if(n>=50){turn_r;Wait(100);n=0;k++;}
      if(k>=3){turn_l;Wait(300);go;Wait(300);k=0;}
      Wait(1);
      }

  if(SENSOR_1 < THRESHOLD -35){
       turn_l;
      }else if(SENSOR_1 < THRESHOLD -7){
       turn_L;
      }else if(SENSOR_1 < THRESHOLD +7){
       go;
      }else if(SENSOR_1 < THRESHOLD +15){
       turn_R;
    
     }else{
      turn_r;
      }Wait(STEP);
     if(SensorUS(S2) <= 8){
      while(f==1){
      tukamu;
      go;
      Wait(3000);
      turn_u;
      go;
      Wait(3000);
      hanasu;
      turn_u;
       f=1;
     }
    }
   }
 }

トップ   編集 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS