PDA

Archiv verlassen und diese Seite im Standarddesign anzeigen : Probleme mit Asuro-Programm



ZDig
20.04.2009, 20:10
Moinsen zusammen,

ich hab mit meinem Programm für Asuro ein Problem: Programmers
Notepad kann es ohne Error in eine .hex-Datei umwandeln, allerdings
passiert immer dasselbe, egal welchen Taster man drückt, obwohl das
doch eigentlich im Programm ausgeschlossen wird. An Lötfehlern dürfte
es nicht liegen, da das Testprogramm reibungsfrei läuft.
Kann mir da vielleicht jemand helfen? Danke schonmal ;-)

ZDig

#include "asuro.h"

int main(void)
{
Init();
if (PollSwitch()<4){
MotorDir(RWD,RWD);
MotorSpeed(120,120);
MotorDir(FWD,BREAK);
MotorSpeed(120,0);
StatusLED(RED);}
if (PollSwitch()>=8){
MotorDir(RWD,RWD);
MotorSpeed(120,120);
MotorDir(BREAK,FWD);
MotorSpeed(120,0);}
else {MotorDir(FWD,FWD);
MotorSpeed(120,120);
StatusLED(GREEN);}

while(1);
return 0;
}

radbruch
20.04.2009, 20:45
Hallo

Dein Programm wird genau einmal ausgeführt bevor es am Ende in der Endlosschleife vor dem return() steckenbleibt. So wäre es vielleicht besser:

#include "asuro.h"

int main(void)
{
Init();
while(1) // Start der Endlosschleife
{
if (PollSwitch() < 4)
{
MotorDir(RWD,RWD);
MotorSpeed(120,120);
MotorDir(FWD,BREAK);
MotorSpeed(120,0);
StatusLED(RED);
}

if (PollSwitch() >= 8)
{
MotorDir(RWD,RWD);
MotorSpeed(120,120);
MotorDir(BREAK,FWD);
MotorSpeed(120,0);
}
else
{
MotorDir(FWD,FWD);
MotorSpeed(120,120);
StatusLED(GREEN);
}
} // Ende der Endlosschleife

return(0);
}
In [ code][ /code]-Tags wäre dein Programm für uns übrigends besser lesbar. Auf die häufig lügende PollSwitch()-Funktion, die Anwendung von "else if" oder auf Zeitverzögerungen möchte ich hier noch nicht näher eingehen. Vielleicht findest du das alles noch selbst raus ;)

Gruß

mic