hey ho ich hab da noch ma so nenn Problem hoffentlich könnt ihr mir weiter helfen also ich wollte nenn Programm schreiben das guckt ob es eine Kollision gibt aber es funktioniert nicht so ganz.
also wenn ich das was jetzt aus kommentiert ist hin schreibe und die Funktion motorFWD aus kommentiere dann funktionieren die Tasten alle aber sonst fährt er die ganze Zeit nach vorne.
wo ist mein Fehler?
Code:
#include "asuro.h"
int main(void)
{
Init();
int i;
MotorSpeed(0,0);
MotorDir(FWD,FWD);
while(1)
{
unsigned char sw;
//MotorDir(FWD,FWD);
//MotorSpeed(0,0);
sw = PollSwitch();
StatusLED(OFF);
FrontLED(OFF);
BackLED(OFF,OFF);
if (sw & 0x01)
Back();
else if (sw & 0x02)
Back();
else if (sw & 0x04)
Back();
else if (sw & 0x08)
Back();
else if (sw & 0x10)
Back();
else if (sw & 0x20)
Back();
MotorFWD();
}
return 0;
}
void MotorFWD()
{
MotorDir(FWD,FWD);
MotorSpeed(120,120);
FrontLED(ON);
return 0;
}
void Turn (void)
{
MotorDir(FWD,RWD);
MotorSpeed(120,120);
BackLED(ON,ON);
StatusLED(RED);
FrontLED(ON);
pSleep(350);
return 0;
}
void Back (void)
{
MotorDir(RWD,RWD);
MotorSpeed(120,120);
BackLED(ON,ON);
StatusLED(GREEN);
FrontLED(ON);
pSleep(500);
Turn();
return 0;
}
void pSleep(int p)
{
int i;
for(i=0;i<=p;i++) { Sleep(72); }
return 0;
}
Lesezeichen