Hi.

Ich habe mir jezt diesen code geschrieben. Leider funktioniert er nur zu hälfte. Findet eine Kollision statt fährt er wie programiert rückwärts. Doch nicht immer so wie er soll. abundzu fährt er einfach 3mal rückwärts, oder er fährt links rückwärts und dann noch zweimal rechts. Wo kann der Fehler liegen?

Code:
#include "asuro.h" 
int main(void) 
{ 
   unsigned int z ,l ,r; 
   unsigned char taste1, taste2;
   Init(); 
   taste2=PollSwitch(); 
   while(1) 
   { 
   
      
      taste1=PollSwitch(); 
      if (taste1 && (taste1==taste2)) 
      { 
			  if (taste1==1) {l=90;r=120;}
			  if (taste1==2) {l=0;r=120;}
			  if (taste1==4) {l=120;r=90;}
			  if (taste1==8) {l=90;r=120;}
			  if (taste1==16) {l=120;r=0;}
			  if (taste1==32) {l=120;r=90;}
         StatusLED(RED); 
         MotorDir(RWD,RWD); 
         MotorSpeed(l,r); 
         for(z=0;z<250;z++) 
         { 
            Sleep(255); 
         } 
      } 
      else 
      { 
         StatusLED(GREEN); 
         MotorDir(FWD,FWD); 
         MotorSpeed(120,120); 
      } 
      taste2=taste1; 
   } 
   return 0; 
}
Danke schonmal im voraus.