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

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

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

 int max;
 int time;
 task main()
   {
     SetSensor(SENSOR_2,SENSOR_LIGHT);
     max = SENSOR_2;
     ClearTimer(0);
     time = Timer(0);
    while(Timer(0) <= 12)
    {
      OnFwd(OUT_A);OnRev(OUT_C);
      if(SENSOR_2 > max)
      {
       ClearTimer(1);
       max = SENSOR_2 ;
      }
      else
      {
       max = max;
       time = Timer(1);
      }
    }
    ClearTimer(1);
    while(Timer(1) <= time)
    {
     OnFwd(OUT_C);
     OnRev(OUT_A);
    }
    OnFwd(OUT_A);
    while(true)
    {
     OnFwd(OUT_A+OUT_C);
     if(SENSOR_2 < max - 3)
     {
      Off(OUT_C);
      ClearTimer(2);
      until((SENSOR_2 >= max - 3) || (Timer(2) == 4));
     }
     if(SENSOR_2 < max - 3)
     {
      Off(OUT_A);
      OnFwd(OUT_C);
      until(SENSOR_2 >= max - 3);
      OnFwd(OUT_A);
     }
    }
 }

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

#comment


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