Hallo & Hilfe !
Ich bin noch ziemlich Neu auf diesem Gebiet und hab da mal ne Frage:
Was gibt mir PollSwitch eigentlich aus, wenn überhauptkeine Taste gedrückt ist? 0 ? Oder 1024 ? ...
Wenn ich die verschiedenen Schalter einzeln abfragen will, kann ich dann nicht schreiben
Vielleicht kann mir einer helfen...Code:/*** Funktion Vorwaerts ***/ void MotorFwd(void) { MotorDir(FWD,FWD); MotorSpeed(speed,speed); Sleep(200); } /*** Funktion Motor Stop ***/ void MotorStop(void) { MotorDir(BREAK,BREAK); MotorSpeed(0,0); Sleep(200); } int main(void) { uint8_t t1, t2; //Variablen für PollSwitch Init(); //Initialisieren EncoderInit(); //Encoder initialisieren while(1) { t1=0; t2=0; /*** Keine Taste -> Vorwärts fahren ***/ while (t1 == 0 && t2 == 0) { MotorFwd(); FrontLED(ON); BackLED(OFF,OFF); t1=PollSwitch; t2=PollSwitch; } MotorStop(); Go(-40,speed); /*** Fall 1 (Wand vorne rechts) ***/ if (t1 == t2 && t1 & 0x01) { Turn(-45,speed); } /*** Fall 2 (Wand vorne links ***/ else if (t1 == t2 && t1 & 0x1F) { Turn(45,speed); } ...
[/code]







Zitieren

Lesezeichen