***[[学習ノート Hypodytes rubripinnis>2005/A5/学習ノート Hypodytes rubripinnis]] [#a6156c61]
***課題3:光を追いかけるプログラム[[課題4右>2005/A5/課題4右]] [#s5521fcd]

*&color(red){現在製作中!しばしお待ちを!!}; [#r655128e]

*光を追いかけるプログラム [#ndcb6561]
 作成者:Hypodytes rubripinnis

 #define go_straight OnFwd(OUT_A+OUT_C);
 #define turn_right OnFwd(OUT_A);OnRev(OUT_C);
 #define turn_left OnFwd(OUT_C);OnRev(OUT_A);
 
 int max;
 int time;
 
 task main()
 {
     SetSensor(SENSOR_2,SENSOR_LIGHT);
     max=SENSOR_2;
     time=Timer(0);
 
     ClearTimer(0);
 
     while(Timer(0)<=12)
     {
         turn_right
         if(SENSOR_2>max)
           {
            ClearTimer(1);
            max=SENSOR_2 ;
           }
         else
           {
            max=max;
            time=Timer(1);
           }
    }
 
    ClearTimer(1);
 
    while(Timer(1)<=time)
    {turn_left}
 
    while(true)
    {
         if(SENSOR_2>=max-20)
           {go_straight}
         if(SENSOR_2<max-20)
           {
            turn_left
            ClearTimer(2);
            until((SENSOR_2>=max-20)||(Timer(2)==5));
           }
         if(SENSOR_2<max-20)
           {
            turn_right
            ClearTimer(2);
            until((SENSOR_2>=max-20)||(Timer(2)==5));
           }
         if(SENSOR_2<max-20)
           {
            turn_right
            until(SENSOR_2>=max-20);
           }
    }
 }

''仕組み&工夫したところ''

#comment


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