OK dalmator,
ich habe mir nochmals den Schaltplan genau angesehen, Fehler gefunden und behoben. Es waren 2 Widerstände vertauscht. Jetzt funktionierts, wenn ich diesen Code verwende:
Damit kriegt allerdings mein Asuro mit der Zeit einen Linksdrall. Ich werde noch dran feilen, möglicherweise hast du mir noch einen Ratschlag...Code:#include "asuro.h" #include "ultrasonic.h" #define MAXDIFF 100 int main(void) { int abstand, abstand_alt, diff, zaehler=0; Init(); abstand = Chirp(); while(TRUE) { abstand_alt = abstand; abstand = Chirp(); ++zaehler; diff = abstand - abstand_alt; if( (abstand>15) && (abs(diff)<MAXDIFF) ) { StatusLED(GREEN); MotorDir(FWD, FWD); MotorSpeed(150, 150); } else if( (abstand>10) && (abstand<=15) && (abs(diff)<MAXDIFF) ) { StatusLED(GREEN); MotorDir(FWD, FWD); MotorSpeed(100, 150); Msleep(30); } else { StatusLED(RED); MotorDir(RWD, RWD); MotorSpeed(150, 100); Msleep(100); } if (zaehler > 400) { StatusLED(RED); BackLED(ON,ON); MotorDir(RWD, RWD); MotorSpeed(200, 250); Msleep(10); BackLED(OFF,OFF); } if (zaehler > 405) { StatusLED(RED); BackLED(ON,ON); MotorDir(RWD, RWD); MotorSpeed(250, 200); Msleep(10); BackLED(OFF,OFF); if(zaehler > 410) zaehler = 0; } } return 0; }
Die Ebay - Nummer vom US-Bausatz ist übrigens 330198321285, wenn's jemanden interessiert.
Gruß
Pinsel







Zitieren

Lesezeichen