i>2000
i ist nie größer als 2000, die Schleife wird deshalb sofort wieder verlassen. Blöd wenn man ungetestete Programme verbreitet. Entschuldigung. Richtig wäre
for(i=0; i<2000; i++)
i>2000
i ist nie größer als 2000, die Schleife wird deshalb sofort wieder verlassen. Blöd wenn man ungetestete Programme verbreitet. Entschuldigung. Richtig wäre
for(i=0; i<2000; i++)
Bild hier
Atmel’s products are not intended, authorized, or warranted for use
as components in applications intended to support or sustain life!
Ok das hätte ich auch selbst sehen können!
Danke nochmal!
Vielen Dank er fährt jetzt so wie ich das möchte.
Jetzt wollte ich eine kleine Modifikation machen und mal was mit den Kollisionsdinger machen:
Jedoch fährt er mir jetzt durch, was nicht sein sollte - aber laut einem anderem Forum, soll man die Abfrage mehrmals, oder so wie oben machen, da verschiedene Werte zurückkommen und man das so umgehen könnte (suchs euch nochmals raus, wenn ihr wollt).Code:#include "asuro.h" int i; int main(void) { Init(); MotorDir(FWD,FWD); MotorSpeed(200,200); StatusLED(GREEN); if ((PollSwitch()!=0) || (PollSwitch()!=0) || (PollSwitch()!=0)) { MotorDir(BREAK,BREAK); MotorSpeed(0,0); StatusLED(RED); for(i=0; i<1000; i++) Sleep(72); MotorDir(FWD,BREAK); MotorSpeed(100,0); StatusLED(GREEN); } while(1); return(0);
Weiters hab ich eine generelle Frage - arbeitet ihr noch immer in der test.c? Welche Dateien von der Original-Cd sind essentiell? Hab diese hier rüberkopiert:
file:///home/davidb/Asuro/AsuroFl.ini
file:///home/davidb/Asuro/Test-all.bat
file:///home/davidb/Asuro/Test-clean.bat
file:///home/davidb/Asuro/asuro.c
file:///home/davidb/Asuro/asuro.d
file:///home/davidb/Asuro/asuro.h
file:///home/davidb/Asuro/asuro.lst
file:///home/davidb/Asuro/asuro.o
file:///home/davidb/Asuro/makefile
file:///home/davidb/Asuro/test.c
file:///home/davidb/Asuro/test.c~
file:///home/davidb/Asuro/test.d
file:///home/davidb/Asuro/test.eep
file:///home/davidb/Asuro/test.elf
file:///home/davidb/Asuro/test.hex
file:///home/davidb/Asuro/test.lss
file:///home/davidb/Asuro/test.lst
file:///home/davidb/Asuro/test.map
file:///home/davidb/Asuro/test.o
file:///home/davidb/Asuro/test_original.c
Brauch ich da wirklich alles? test.c ist ja meine und asuro.h brauch ich ja auch...
Macht ihr euch eigentlich eigene Programme? Was müsste ich dazu beachten. Ist es überhaupt ratsam, weil normal reicht es ja aus, wenn man immer in der test.c arbeitet, man kann sie anders abspeichern wenn man verschiedene Programme abspielen will...
So jetzt hab ich noch eine Modifikation gemacht, doch das If wird bei Kollision trotzdem nicht ausgeführt. Fahren tut er brav!
Code:#include "asuro.h" int i; int main(void) { Init(); if (PollSwitch()==0 && PollSwitch()==0 && PollSwitch()==0 && PollSwitch()==0) { MotorDir(FWD,FWD); MotorSpeed(200,200); BackLED(ON,ON); } if (PollSwitch()!=0 && PollSwitch()!=0 && PollSwitch()!=0 && PollSwitch()!=0) { MotorDir(BREAK,BREAK); MotorSpeed(0,0); StatusLED(RED); MotorDir(FWD,BREAK); MotorSpeed(100,0); StatusLED(GREEN); } while(1); return(0); }
Geändert von brandy_000 (04.01.2012 um 18:32 Uhr)
Hallo,
du musst die If-Abfrage in die while-Schleife tun, sonst fragt er nur beim Starten die Taster ab und bleibt danach in der Endlosschleife.
Grüße,
oernie97
Ja das hab ich jetzt schon gemacht - jedoch auch ohne Ergebnis - er fährt einfach nicht los:
Code:#include "asuro.h" int i; int main(void) { Init(); while(1); if (PollSwitch()==0 && PollSwitch()==0 && PollSwitch()==0 && PollSwitch()==0) { MotorDir(FWD,FWD); MotorSpeed(200,200); BackLED(ON,ON); StatusLED (GREEN); } else { MotorDir(BREAK,BREAK); MotorSpeed(0,0); BackLED(OFF,OFF); StatusLED(RED); MotorDir(FWD,BREAK); MotorSpeed(100,0); } return(0); }
Ich meine _in_ die while-Schleife (bedeutet, das Semikolon hinter while (1) wird zu einer geöffneten geschweiften Klammer und vor return(0); wird eine geschlossene geschweifte Klammer eingefügt).
Lesezeichen