I've searched in the program if there is one missing, but I hadn't found something (sorry for my bad english).
Here's my program (isn't finished yet):
Code: Select all
task main()
{
long xmax ;
long ymax ;
int weiß ;
int neunziggrad[120];
int xturns;
int yturns;
int rechts;
int drehungen;
int links[];
int rwinkel[90];
int sec = 0;
int weis = 90;
SetSensor(IN_1, SENSOR_LIGHT); //Rechts
SetSensor(IN_2, SENSOR_LIGHT); //Links
}
sub motorRechts(int drehungen)
{RotateMotor(OUT_A, 30, drehungen*360);}
sub motorLinks(int drehungen)
{RotateMotor(OUT_B, 30, drehungen*360);}
task rechterwinkel ()
{
while (rwinkel=1);
{
OnFwd(OUT_C, 75);
OnFwd(OUT_B, 75) ;
if (SENSOR_1 == 1); //Rechts wird getroffen
{
if (links=1)
{
Off(OUT_C); //bf
Off(OUT_B);
rechts = 0;
links = 0;
}
OnRev(OUT_C, 75); //Beide Rückwärts
OnRev(OUT_B, 75);
rechts = 1;
Wait(150);
OnFwd(OUT_C, 75); //Links vorwärts
Wait(50);
OnFwd(OUT_B, 75); //Rechts vorwärts
}
if (SENSOR_2 == 1) //Links wird getroffen
{
if (rechts == 1)
{
Off(OUT_C);
Off(OUT_B);
rechts = 0;
links = 0;
}
OnRev(OUT_C, 75); //Beide Rückwärts
OnRev(OUT_B, 75);
links = 1;
Wait(150);
OnFwd(OUT_B, 75); //Rechts vorwärts
Wait(50);
OnFwd(OUT_C, 75); //Links vowärts
}
if ((SENSOR_2 == 1)&&(SENSOR_1 == 1))
{
Off(OUT_C);
Off(OUT_B);
rechts = 0;
links = 0;
rwinkel=1
}
task feldfahrt() //1
{
while ((SENSOR_1 < 90) && (SENSOR_2 < 90))
{
motorRechts(1);
motorLinks(1);
}
start rechterwinkel;
until (rwinkel = 1);
OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);
while((SENSOR_1 > weiß) && (SENSOR_2 < weiß))
{
start motorRechts(1);
start motorLinks(1);
xturns = xturns +1;
}
xmax = xturns;
xturns = 0;
OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);
RotateMotor(OUT_B + OUT_A, 30, xmax*360/2);
xturns = xmax/2
OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(neunziggrad);
while((SENSOR_1 > weiß) && (SENSOR_2 < weiß))
{
start motorRechts(1);
start motorLinks(1);
}
OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);
while((SENSOR_1 > weiß) && (SENSOR_2 < weiß))
{
motorRechts(1);
motorLinks(1);
yturns = yturns +1;
}
ymax = yturns;
yturns = 0;
OnFwd(OUT_A, 30);
OnRev(OUT_B, 30);
Wait(2*neunziggrad);
RotateMotor(OUT_B + OUT_A, 30, xmax*360/2);
yturns = ymax/2
while (sec < 61)
{
PlayTone(100, 100);
Wait (100) ;
sec = sec +1;
}
start Legos ;
}
task Legos()
{}
start feldfahrt
{}
I hope somebody can help me...it is important cause it's a school project.
Thx