Hallo
Das return() befindet sich innerhalb der deshalb nicht mehr endlosen while-Schleife:
Ich würde es vielleicht so formulieren:Code:#include "asuro.h" int grad=0; int main(void) { Init(); while(1) { if(PollSwitch()==0) { MotorDir(FWD,FWD); MotorSpeed(100,100); } else if(PollSwitch()!=0) { if(grad==0) { MotorDir(FWD,FWD); MotorSpeed(100,0); Msleep(200); grad = 1 ; } } else if(PollSwitch()!=0 && grad==1) { if(grad==1) { MotorDir(FWD,FWD); MotorSpeed(0,100); Msleep(400); grad = 0 ; } } return 0; } }
(ungetestet)Code:#include "asuro.h" int grad=0; int main(void) { Init(); while(1) { if(PollSwitch()==0) { StatusLED(GREEN); MotorSpeed(100,100); } else { if(grad==0) { StatusLED(RED); MotorSpeed(100,0); Msleep(200); grad = 1; } else { StatusLED(YELLOW); MotorSpeed(0,100); Msleep(400); grad = 0; } } } return 0; }
Der Ansatz erscheint mir etwas zu einfach.
Gruß
mic







Zitieren


Lesezeichen