- 追加された行はこの色です。
- 削除された行はこの色です。
[[2005/A3]]
**ロボットに「右」を書かせてみよう 作成者 tatsu [#j5526639]
*ポイント:何とかして手書きの「右」に近づけようと思い、なめらかさを出した。 [#kfd97712]
**命令 [#uaf5dcf2]
int move_time;
task main()
{
move_time=80;
OnFwd(OUT_A);
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;
OnRev(OUT_A+OUT_C);
OnRev(OUT_A+OUT_C); //5秒前進
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; //6秒直進
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; //3秒直進
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; //モータAとモータCを逆回転させる
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; //8秒直進
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;
OnFwd(OUT_A);
OnFwd(OUT_A); //さらに4秒右に曲がる
OnRev(OUT_C);
Wait(move_time);
Off(OUT_A+OUT_C+OUT_B);
move_time=40;
move_time=40; //4秒直進
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; // モータAとモータCを逆回転
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; //5秒機体を後退させる
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