Hallo,
ich habe hier folgendes Linienprogramm, das den Asuro über zwei schwarze Linien außen und eine weiße in der Mitte leiten soll. Das funktioniert soweit auch. Nun möchte ich, dass der Asuro bei einer Kollision mit einem Hindernis anhält. Leider weiß ich genau, wo diese Abfrage in das Programm rein muss, vielleicht ist sie auch falsch formuliert, jedenfalls funktioniert es nicht.
Hier das Programm:
Code:
#include "asuro.h"
#define dunkel 50
#define rechts 1
#define links 0
void warte (int s)
{
int x = 0;
for (x = 0; x <s; x++) Sleep(72);
}
int main(void)
{
Init();
unsigned int Licht[2];
int white;
FrontLED(ON);
warte(1000);
LineData(Licht);
white = (Licht[links]+Licht[rechts])/2-60;
MotorDir(FWD,FWD);
MotorSpeed(180,180);
int i = 0;
while (1)
{
LineData(Licht);
MotorSpeed(180,180);
if(PollSwitch()>0)
{
MotorDir(BREAK,BREAK);
MotorSpeed(0,0);
}
while (Licht[links] > white && Licht[rechts] > white)
{
MotorDir(FWD,FWD);
LineData(Licht);
}
MotorSpeed(180,180);
while (Licht[links] < white)
{
MotorDir(FWD,BREAK);
LineData(Licht);
while (Licht[rechts] < white)
{
MotorSpeed(255,180);
LineData(Licht);
while (Licht[links] > white)
{
MotorSpeed(255,180);
LineData(Licht);
}
}
MotorSpeed(180,180);
}
MotorSpeed(180,180);
while (Licht[rechts] < white)
{
MotorDir(BREAK,FWD);
LineData(Licht);
while (Licht[links] < white)
{
MotorSpeed(180,255);
LineData(Licht);
while (Licht[rechts] > white)
{
MotorSpeed(180,255);
LineData(Licht);
}
}
MotorSpeed(180,180);
}
}
MotorDir(BREAK,BREAK);
MotorSpeed(0,0);
return 0;
}
Schon mal Danke im Voraus.
Lesezeichen