[[2017a/Member]]

 #define go_straight  OnFwd(OUT_AC); Wait(25); Off(OUT_AC);     //交差点直進

 #define cross_right  Off(OUT_AC); Wait(3); OnFwd(OUT_A );     //右折
 #define turn_right  Off(OUT_AC); Wait(3); \
                                   OnFwd(OUT_A); OnRev(OUT_C); ClearTimer(0);      //右回転
 #define right_angle  OnFwd(OUT_AC); Wait(25); \
                                     Off(OUT_AC); OnFwd(OUT_A); OnRev(OUT_C); Wait(52);  Off(OUT_AC);     //右回転(直角)

 #define cross_left  Off(OUT_AC); Wait(3); OnFwd(OUT_C);     //左折
 #define turn_left  Off(OUT_AC); Wait(3); \
                                OnFwd(OUT_C); OnRev(OUT_A);     //左回転
 #define left_angle  OnFwd(OUT_AC); Wait(25); Off(OUT_AC);\
                                  OnFwd(OUT_C); OnRev(OUT_A); Wait(77); Off(OUT_AC);     //右回転(直角)



 task main(){
  SetPower(OUT_AC,5);
  SetSensor(SENSOR_2,SENSOR_LIGHT);

  int a=0;
  while( a < 5 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    a++;
    }
   }     //ここまでE

  PlaySound(SOUND_UP);

  right_angle;
  int b=0;
  while( b < 4 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 40 ){
    cross_right;
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    b++;
    }
   }     //ここまでP

  Off(OUT_AC);
  Wait(100);
  PlaySound(SOUND_DOWN);

  left_angle;
  int c=0;
  while( c < 4 ){
   if(SENSOR_2 >= 50){
    turn_right; 
    } else if(SENSOR_2 >= 45 ){
    cross_right;
    } else if(SENSOR_2 >= 40 ){
    cross_left; 
    } else if(SENSOR_2 >= 30 ){
    turn_left;
    c++;
    }
   }     //ここまでQ

  go_straight;
  int d=0;
  while( d < 4 ){
   if(SENSOR_2 >= 50){
    turn_right; 
    } else if(SENSOR_2 >= 45 ){
    cross_right;
    } else if(SENSOR_2 >= 40 ){
    cross_left; 
    } else if(SENSOR_2 >= 30 ){
    turn_left;
    d++;
    }
   }     //ここまでR

  go_straight;
  int e=0;
  while( e < 5 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_light; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    e++;
    }
   }     //ここまでT

  PlaySound(SOUND_DOWN);

  go_straight;
  int f=0;
  while( f < 6 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right; 
    f++;
    }
   }     //一周してTに戻る
  
  PlaySound(SOUND_DOWN);

  go_straight;
  int g=0;
  while( g < 11 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    g++;
    }
   }     //ここまでH
 
  PlaySound(SOUND_UP);

  right_angle;
  int h=0;
  while( h < 60 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    h++;
    }
   }     //ここまでG
 
  PlaySound(SOUND_UP);

  right_angle;
  int i=0;
  while( i < 3 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    i++;
    }
   }     //ここまでS

  PlaySound(SOUND_DOWN);
  Off(OUT_AC);
  Wait(100);

  left_angle;
  int j=0;
  while( j < 4 ){
   if(SENSOR_2 >= 50){
    turn_right; 
    } else if(SENSOR_2 >= 45 ){
    cross_right;
    } else if(SENSOR_2 >= 40 ){
    cross_left; 
    } else if(SENSOR_2 >= 30 ){
    turn_left;
    j++;
    }
   }     //ここまでP

  PlaySound(SOUND_UP);

  go_straight;
  int k=0;
  while( k < 4 ){
   if(SENSOR_2 >= 50){
    turn_right; 
    } else if(SENSOR_2 >= 45 ){
    cross_right;
    } else if(SENSOR_2 >= 40 ){
    cross_left; 
    } else if(SENSOR_2 >= 30 ){
    turn_left;
    k++;
    }
   }     //ここまでQ

  PlaySound(SOUND_UP);

  go_straight;
  int l=0;
  while( l < 5 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37 ){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    l++;
    }
   }     //ここまでF

  PlaySound(SOUND_UP);

  right_angle;
  int m=0;
  while( m < 10 ){
   if(SENSOR_2 >= 50){
    turn_left; 
    } else if(SENSOR_2 >= 45 ){
    cross_left;
    } else if(SENSOR_2 >= 37){
    cross_right; 
    } else if(SENSOR_2 >= 30 ){
    turn_right;
    m++;
    }
   }     //スタート地点に戻る

  Off(OUT_AC);
  PlaySound(SOUND_DOWN);
 }     //停止して終了


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