- 追加された行はこの色です。
- 削除された行はこの色です。
[[2019a/Member]]
int z;
sub follow_leftline()
{
SetSensor(SENSOR_2, SENSOR_LIGHT);
ClearTimer(0);
while(FastTimer(0)<z){
if(SENSOR_2>44){OnFwd(OUT_A);OnRev(OUT_C);ClearTimer(0);}
else if(SENSOR_2>42){OnFwd(OUT_A);ClearTimer(0);}
else if(SENSOR_2>38){OnFwd(OUT_AC);ClearTimer(0);}
else if(SENSOR_2>36){OnFwd(OUT_C);ClearTimer(0);}
else if(SENSOR_2>32){OnFwd(OUT_C);OnRev(OUT_A);}
}
}
sub follow_rightline()
{
SetSensor(SENSOR_2, SENSOR_LIGHT);
ClearTimer(0);
while(FastTimer(0)<z){
if(SENSOR_2>44){OnFwd(OUT_C);OnRev(OUT_A);ClearTimer(0);}
else if(SENSOR_2>42){OnFwd(OUT_C);ClearTimer(0);}
else if(SENSOR_2>38){OnFwd(OUT_AC);ClearTimer(0);}
else if(SENSOR_2>36){OnFwd(OUT_A);ClearTimer(0);}
else if(SENSOR_2>32){OnFwd(OUT_A);OnRev(OUT_C);}
}
}
sub back_follow_right()
{
SetSensor(SENSOR_2, SENSOR_LIGHT);
ClearTimer(0);
while(FastTimer(0)<z){
if(SENSOR_2>44){OnFwd(OUT_C);OnRev(OUT_A);ClearTimer(0);}
else if(SENSOR_2>42){OnRev(OUT_A);ClearTimer(0);}
else if(SENSOR_2>38){OnRev(OUT_AC);ClearTimer(0);}
else if(SENSOR_2>36){OnRev(OUT_C);ClearTimer(0);}
else if(SENSOR_2>32){OnFwd(OUT_A);OnRev(OUT_C);}
}
}
sub migikaiten()
{
OnFwd(OUT_AC);
Wait(20);
Off(OUT_AC);
OnFwd(OUT_A);
OnRev(OUT_C);
Wait(40);
Off(OUT_AC);
OnFwd(OUT_AC);
Wait(20);
Off(OUT_AC);
}
task main()
{
SetSensor(SENSOR_2, SENSOR_LIGHT);
z=35;
follow_rightline();
Off(OUT_AC);
Wait(100);
OnFwd(OUT_AC);
Wait(30);
Off(OUT_AC);
z=20;
follow_leftline();
Off(OUT_AC);
Wait(100);
OnFwd(OUT_AC);
Wait(20);
Off(OUT_AC);
OnFwd(OUT_A);OnRev(OUT_C);
Wait(160);
Off(OUT_AC);
OnRev(OUT_AC);
Wait(30);
Off(OUT_AC);
Wait(100);
z=20;
back_follow_right();
Off(OUT_AC);
OnRev(OUT_AC);
Wait(30);
Off(OUT_AC);
OnRev(OUT_B);
Wait(10);
Off(OUT_B);
OnFwd(OUT_A);
OnRev(OUT_C);
Wait(30);
Off(OUT_AC);
z=20;
follow_rightline();
Off(OUT_AC);
Wait(100);
OnFwd(OUT_AC);
Wait(20);
Off(OUT_AC);
z=20;
follow_leftline();
Off(OUT_AC);
Wait(100);
migikaiten();
z=20;
follow_leftline();
Off(OUT_AC);
Wait(100);
migikaiten();
z=20;
follow_leftline();
Off(OUT_AC);
Wait(100);
OnFwd(OUT_C);OnRev(OUT_A);
Wait(90);
Off(OUT_AC);
z=20;
follow_leftline();
Off(OUT_AC);
Wait(100);
OnFwd(OUT_C);OnRev(OUT_A);
Wait(90);
Off(OUT_AC);
OnFwd(OUT_A);OnRev(OUT_C);
Wait(40);
Off(OUT_AC);
z=20;
follow_rightline();
Off(OUT_AC);
OnFwd(OUT_AC);
Wait(30);
Off(OUT_AC);
z=20;
follow_rightline();
Off(OUT_AC);
OnFwd(OUT_A);OnRev(OUT_C);
Wait(110);
Off(OUT_AC);
OnFwd(OUT_B);
Wait(10);
Off(OUT_B);
}