Professional Documents
Culture Documents
Leader
Leader
#define fois_circle 12
#define reposer Wait(500);
#define SEARCH 23
#define Turn_LeftNinety()
(d + 90) % 360;
#define Turn_RightNinety()
(d - 90) % 360;
#define Forward_Forty()
#define Turn_RightThirty()
= (d - 30) % 360;
}
void Turn_RightThirty_Check(int m, int i)
{
if(SensorUS(IN_4) <= SEARCH)
{
RotateMotor(OUT_AC, 30, 720); // go to check the ball
OnRev(OUT_B, 20);//do not release the motor
Wait(3000);
if(SENSOR_3 == 5)
{
RotateMotor(OUT_AC, 30, -720); //return
Go_Back(m-i);
}
else
{
OnFwd(OUT_B, 20);
Wait(3000);
Off(OUT_B);
RotateMotor(OUT_AC, 30, -720); //return
}
}
RotateMotorEx(OUT_AC, 50, 115, -100, true, true);
d = (d - 30) % 360;
NumOut(0, LCD_LINE4, d);
reposer;
}
task MovLead()
{
int i = 0;
while(true)
{
//(0,0,90)
reposer;
repeat(fois_forward)
{
Forward_Forty(); //forward one step
y++;
i = 0;
repeat(fois_circle)
{
Turn_RightThirty_Check(fois_circle, i);
i++;
}
}
//(0,350,90)
reposer;
Turn_RightNinety();
Forward_Forty();
x++;
i = 0;
repeat(fois_circle)
{
Turn_RightThirty_Check(fois_circle, i);
i++;
}
Turn_RightNinety();
//(40, 350, 270)
reposer;
repeat(fois_forward)
{
Forward_Forty();
y--;
i = 0;
repeat(fois_circle)
{
Turn_RightThirty_Check(fois_circle, i);
i++;
}
}
//(40, 0 270)
reposer;
Turn_RightNinety();
Forward_Forty();
x--;
Forward_Forty();
x--;
i = 0;
repeat(fois_circle)
{
Turn_RightThirty_Check(fois_circle, i);
i++;
}
Turn_RightNinety();
//(-40, 0, 90)
reposer;
repeat(fois_forward)
{
Forward_Forty();
y++;
i = 0;
repeat(fois_circle)
{
Turn_RightThirty_Check(fois_circle, i);
i++;
}
}
//(-40, 350, 90)
reposer;
Turn_RightNinety();
Forward_Forty();
x++;
repeat(fois_circle)
{
Turn_RightThirty_Check(fois_circle, i);
i++;
}
Turn_RightThirty();