So, das klappt jetzt, vielen Dank.
Hier der endgültige Quellcode:
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); while (1) if (PINC & (1<<PC4)) { StatusLED(GREEN); LineData(Licht); MotorSpeed(180,180); 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); } } else { StatusLED(RED); MotorDir(BREAK,BREAK); MotorSpeed(0,0); } return 0; }







Zitieren

Lesezeichen