[[2017b/Member]]
#define rightSENKAI OnFwd(OUT_A);OnRev(OUT_C);
#define rightMAGARU OnFwd(OUT_A);Off(OUT_C);
#define leftSENKAI OnFwd(OUT_C);OnRev(OUT_A);
#define leftMAGARU OnFwd(OUT_C);Off(OUT_A);
#define middle 41
#define carb 41
#define ch OnFwd(OUT_B);Wait(10);Off(OUT_B);
#define re OnRev(OUT_B);Wait(5);Off(OUT_B);
#define go(t) OnFwd(OUT_AC);Wait(t);Off(OUT_AC);
#define back(t) OnRev(OUT_AC);Wait(t);Off(OUT_AC);
#define TURN_RIGHT OnFwd(OUT_A);OnRev(OUT_C);until(SENSOR_2<=40);Off(OUT_AC);
#define TURN_LEFT OnFwd(OUT_C);OnRev(OUT_A);until(SENSOR_2>=50);Off(OUT_AC);
#define cross_stop Off(OUT_AC);Wait(100);

sub r()
{
 SetSensor(SENSOR_2,SENSOR_LIGHT);
 ClearTimer(0);
 while(FastTimer(0)<=21)
 {
  if(SENSOR_2>middle+5)    
   {
    rightSENKAI
    ClearTimer(0);
   }
  else if(SENSOR_2>middle+3)    
   {
    rightMAGARU
    ClearTimer(0);
   }
  else if(SENSOR_2>middle)   
   {
    OnFwd(OUT_AC);
    ClearTimer(0);
   }
  else if(SENSOR_2>middle-3)    
   {
    leftMAGARU
    ClearTimer(0);
   }
  else    
   {
    leftSENKAI
    }
  }
Off(OUT_AC);
}
sub l()
{
 SetSensor(SENSOR_2,SENSOR_LIGHT);
 ClearTimer(0);
 while(FastTimer(0)<=21)
 {
  if(SENSOR_2>carb+5)    
   {
    leftSENKAI
    ClearTimer(0);
   }
  else if(SENSOR_2>carb+3)    
   {
    leftMAGARU
    ClearTimer(0);
   }
  else if(SENSOR_2>carb)   
   {
    OnFwd(OUT_AC);
    ClearTimer(0);
   }
  else if(SENSOR_2>carb-3)    
   {
    rightMAGARU
    ClearTimer(0);
   }
  else    
   {
    rightSENKAI
    }
  }
Off(OUT_AC);
}



task main ()
{r();
 cross_stop;//B
 go(35);
 r();
 cross_stop;//C
 leftSENKAI;
 Wait(30);
 r();
 cross_stop;//F
 go(35);
 r();
 cross_stop;//2cb
 go(25);
 l();
 cross_stop;//R
 rightSENKAI;
 Wait(30);
 l();
 cross_stop;//P
 ch;
 go(25);
 l();//Q
 go(20);
 r();
 cross_stop;//S
 go(30);
 r();
 cross_stop;//S2
 go(50);
 rightSENKAI;
 Wait(65);
 l();
 cross_stop;//F
 ch;
 rightSENKAI;
 Wait(160);
 re;
 back(45);
 leftSENKAI;
 Wait(160);
 r();
 cross_stop;//C
 leftSENKAI;
 Wait(90);
 go(90);
 
}

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