#define HIPOWER 1
#define LOWPOWER 3
#define set_power_H SetPower(OUT_AC,HIPOWER);
#define set_power_L SetPower(OUT_AC,LOWPOWER);
#define go_forward set_power_H; OnFwd(OUT_AC);
#define turn_left1 set_power_L;\
  OnFwd(OUT_C); OnRev(OUT_A);
#define turn_left0 set_power_L;\
  OnFwd(OUT_C); Off(OUT_A);
#define turn_right0 set_power_L;\
  OnFwd(OUT_A); Off(OUT_C);
#define turn_right1 set_power_L;\
  OnFwd(OUT_A); OnRev(OUT_C);
#define SIGNALON 13
#define cross set_power_H; OnFwd(OUT_AC);Wait(20); 
#define c1 if (SENSOR_3 < 37) {Off(OUT_AC); SendMessage(SIGNALON);Wait(80);}

task main()
{
  SetSensor(SENSOR_2,SENSOR_LIGHT);
  SetSensor(SENSOR_3,SENSOR_LIGHT);
  
  int nl=0;
  int cc=0;
  go_forward;
  Wait(460);
  turn_left1;
  Wait(140);
  go_forward;
  Wait(280);
  
  
   
  ClearTimer(0);
  while (true) {
  
  while ((nl < 5) ||(FastTimer(0)<500)){
    if (SENSOR_2 < 37) {
      turn_left1;
       nl++;
    } else if (SENSOR_2 < 41) {
      turn_left0;   
 nl=0;
    } else if (SENSOR_2 < 45) {
      go_forward;   
 nl=0;
    } else if (SENSOR_2 < 50) {
      turn_right0;  
    } else {
       turn_right1; 
 nl=0;
    }
      
    Wait(1);
  }
  
  turn_right1; Wait(35);
  cross;
  cc++;
  if (cc == 1) {
  go_forward;
  Wait(50);
  c1;
  OnRev(OUT_AC);
  Wait(150);
  turn_left1;
  Wait(40);
  go_forward;
  Wait(280);
  c1;
  OnRev(OUT_AC);
  Wait(500);
  turn_left1;
  Wait(100);
  go_forward;
  Wait(200);
  c1;
  OnRev(OUT_AC);
  Wait(100);
  turn_left1;
  Wait(330);
  go_forward;
  Wait(1000);
  
}
}
}


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