Hallo
Versuche es mal so:
(ungetestet)Code:/************************************************** ************************* * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * any later version. * ************************************************** *************************/ #include <asuro.h> void sleep_ms(int ms) { while(ms>0) { Sleep(72); ms=ms-1; } } void hindernis_rechts(void) { MotorDir(BREAK,BREAK); MotorSpeed(0,0); sleep_ms(2000); FrontLED(OFF); StatusLED(YELLOW); BackLED(ON,ON); MotorDir(FWD,FWD); MotorSpeed(100,50); sleep_ms(2000); BackLED(OFF,OFF); MotorDir(BREAK,BREAK); MotorSpeed(0,0); sleep_ms(5000); } void hindernis_links(void) { MotorDir(BREAK,BREAK); MotorSpeed(0,0); sleep_ms(2000); FrontLED(OFF); StatusLED(YELLOW); BackLED(ON,ON); MotorDir(FWD,FWD); MotorSpeed(50,100); sleep_ms(2000); BackLED(OFF,OFF); MotorDir(BREAK,BREAK); MotorSpeed(0,0); sleep_ms(5000); } int main (void){ unsigned int Switch1, Switch2; Init(); Switch2=PollSwitch(); while(1) { FrontLED(ON); StatusLED(GREEN); MotorDir(RWD,RWD); MotorSpeed(175,175); Switch1=PollSwitch(); if ((Switch1 == Switch2) && (Switch1 != 0)) { StatusLED(RED); if(Switch1<=7) { BackLED(OFF,ON); hindernis_rechts(); } else { BackLED(ON,OFF); hindernis_links(); } } else BackLED(OFF,OFF); Switch2=Switch1; } }
Änderungen:
main()-Aufrufe am Ende der Ausweichfunktionen entfernt. else-Zweig in Klammern gesetzt:
else
{
BackLED(ON,OFF);
hindernis_links();
}
und Mehrfachabfrage von PollSwitch() eingefügt.
Gruß
mic





 
			
			
 
					
					
					
						 Zitieren
Zitieren [EDIT] Sorry Markusj: ... mehrere Personen...
 [EDIT] Sorry Markusj: ... mehrere Personen...

Lesezeichen