[[2005/A3/課題2]]

[[2005/A3]]

**ロボットに「右」を書かせてみよう            作成者 tatsu                         [#j5526639]

*ポイント:何とかして手書きの「右」に近づけようと思い、なめらかさを出した。 [#kfd97712]
     
**命令 [#uaf5dcf2]
   
  int move_time;

task main()
{  
   move_time=80;
   move_time=80;                //一角目を書く
     OnFwd(OUT_A);
     OnRev(OUT_C);
     Wait(move_time);
   
   move_time=20;
   move_time=20;             //ペンを上げる                   
     OnFwd(OUT_B);
     Wait(move_time);
     Off(OUT_B);
   
   move_time=89;
   move_time=89;            //回転させる
     OnRev(OUT_A);
     OnFwd(OUT_C);
     Wait(move_time);
   
   move_time=15;  
   move_time=15;              //後退させる
     OnRev(OUT_A+OUT_C);
     Wait(move_time);
   
   move_time=20;
   move_time=20;             //ペンを下ろす
    OnRev(OUT_B);
    Wait(move_time);
    Off(OUT_A+OUT_C+OUT_B);
    Wait(50);
   
  move_time=85;
  move_time=85;              //直進させる
     OnFwd(OUT_A+OUT_C);
     Wait(move_time);
  
  move_time=20;
  move_time=20;              //ペンを上げる
    OnFwd(OUT_B);
    Wait(move_time);
    Off(OUT_B);   
   
  move_time=75;
  move_time=75;             //右に曲がる
     OnFwd(OUT_A);
     OnRev(OUT_C);
     Wait(move_time);
     Off(OUT_A+OUT_C+OUT_B);
     
  move_time=50;
  move_time=50;              //前進する
   OnRev(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
  
  move_time=20;
  move_time=20;            //ペンを下ろす
    OnRev(OUT_B);
    Wait(move_time);
    Off(OUT_B);
  
  move_time=60; 
  move_time=60;            //前進する
   OnFwd(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
  
  move_time=40;
  move_time=40;           //ペンを上げる
    OnFwd(OUT_B);
    Wait(move_time);
    Off(OUT_B);
  
  move_time=30; 
  move_time=30;             //もう一歩前進
   OnFwd(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
   
  move_time=70;
  move_time=70;               //左に曲がる
     OnRev(OUT_A);
     OnFwd(OUT_C);
     Wait(move_time);
     Off(OUT_A+OUT_C+OUT_B);
     
  move_time=73;
  move_time=73;                  //後退する
   OnRev(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
   
  move_time=30;
  move_time=30;                      //ペンを下ろす
    OnRev(OUT_B);
    Wait(move_time);
    Off(OUT_B);
    
  move_time=80;
     
  move_time=80;                   //前進する
   OnFwd(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
   
  move_time=40;
  move_time=40;                     //右に曲がる
     OnFwd(OUT_A);
     OnRev(OUT_C);
     Wait(move_time);
     Off(OUT_A+OUT_C+OUT_B);  
     
  move_time=40;
  move_time=40;                   //ペンを上がる
    OnFwd(OUT_B);
    Wait(move_time);
    Off(OUT_B);
    
  move_time=40;
  move_time=40;                     //引続き右に曲がる
     OnFwd(OUT_A);
     OnRev(OUT_C);
     Wait(move_time);
     Off(OUT_A+OUT_C+OUT_B);
       
  move_time=40;
  move_time=40;                     //前進する
   OnFwd(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);   

  move_time=76;
  move_time=76;                       //右に曲がる
     OnFwd(OUT_A);
     OnRev(OUT_C);
     Wait(move_time);
     Off(OUT_A+OUT_C+OUT_B);
     
  move_time=95;
  move_time=95;                             //後退させる
   OnRev(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
   
  move_time=40;
  move_time=40;                        //ペンを下ろす
    OnRev(OUT_B);
    Wait(move_time);
    Off(OUT_B);
 
 move_time=50;
 move_time=50;                        //最後の一角を書く
   OnRev(OUT_A+OUT_C);
   Wait(move_time);
   Off(OUT_A+OUT_C);
   
 move_time=40;
 move_time=40;                      //ペンを上げる
    OnFwd(OUT_B);
    Wait(move_time);
    Off(OUT_B);
       
}

*終わってみて [#vd358210]
     [反省]
           ・時間が合わなかった。
           ・長いプログラムになってしまった。          
     [感想] 
         簡単な漢字を書くことにこんなに手こずるとは思わなかった。 説明書どうりではなく、自分で作るということの大切さが思いだされた。

*コメントお願いします [#o84c87fb]
-関数やサブルーチンを使うと、もう少し短くてすっきりしたプログラムになると思います。また、何画目の動作のための命令なのか、などがわかるようにコメント文を入れておきましょう。 -- [[松本(教員)]] &new{2005-11-21 (月) 14:31:01};

#comment



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