[[2005/C2/どみ]]
*文字を書くロボット [#mefc2a60]

 #define TURN_TIME 148/90°曲がる時間

 sub go_fwd() {/前に進む
 	OnFwd(OUT_A+OUT_C);
 }

 sub go_rev() {
 	OnRev(OUT_A+OUT_C);
 }

 sub turn_right() {
 	OnFwd(OUT_A);
 	OnRev(OUT_C);
 }

sub turn_left() {
	OnFwd(OUT_C);
	OnRev(OUT_A);
	}

sub stop_ac() {
	Off(OUT_A+OUT_C);
	Wait(50);
}

sub pen_down() {
	OnFwd(OUT_B);
	Wait(18);
	Off(OUT_B);
	Wait(50);
}

sub pen_up() {
	OnRev(OUT_B);
	Wait(10);
	Off(OUT_B);
	Wait(50);
}

task main() {
//1
	pen_down();
	OnFwd(OUT_A);
	Wait(120);
	stop_ac();
	pen_up();

	go_fwd();
	Wait(40);
	stop_ac();
	turn_left();
	Wait(140);
	stop_ac();
	go_rev();
	Wait(80);
	stop_ac();
//2
	pen_down();
	go_fwd();
	Wait(100);
	stop_ac();
	pen_up();

	turn_right();
	Wait(TURN_TIME);
	stop_ac();
	go_rev();
	Wait(60);
	stop_ac();
//3
	pen_down();
	go_fwd();
	Wait(45);
	stop_ac();
	pen_up();

	go_fwd();
	Wait(25);
	stop_ac();
	turn_left();
	Wait(TURN_TIME);
	stop_ac();
	go_rev();
	Wait(75);
	stop_ac();
//4-1
	pen_down();
	go_fwd();
	Wait(55);
	stop_ac();
	pen_up();

	go_fwd();
	Wait(75);
	stop_ac();
	turn_right();
	Wait(TURN_TIME);
	stop_ac();
	go_rev();
	Wait(75);
	stop_ac();
//4-2
	pen_down();
	go_fwd();
	Wait(45);
	stop_ac();
	pen_up();

	go_fwd();
	Wait(70);
	stop_ac();
	turn_right();
	Wait(TURN_TIME);
	stop_ac();
	go_rev();
	Wait(20);
	stop_ac();
//5
	pen_down();
	go_rev();
	Wait(55);
	stop_ac();
	pen_up();
}

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