Ich hab das jetz anstelle des Msleepeingesetz abber dann steht da 4 mal
Test.c:**: error: expected ':', ','or ')' before numerik constant
Druckbare Version
Ich hab das jetz anstelle des Msleepeingesetz abber dann steht da 4 mal
Test.c:**: error: expected ':', ','or ')' before numerik constant
Und wen Ich Diesen Error anklicken fürt der mich immer in die zeile die den error verusacht und das ist die zeile mit:
void Msleep(int dauer)
Gruß
Chief
Da hast du irgendwo noch ein : oder ein , oder eine ) vergessen. Poste doch mal den Bereich mit ein paar Zeilen davor und danach. Oder gleich alles...
Gruß
mic
Ok :
Code:#include "asuro.h"
#define LIMIT 20 // Helligkeitsveraenderung, bei der eine Linie detektiert wird
#define TIEFPASS 50 // grosser Wert=grosse Zeitkonstante
// globale Variablen
uint16_t HellLinks;
uint16_t HellRechts;
/*************************************************************************
uint8_t testhell()
testhell ermittelt die durchschnittliche Helligkeit der beiden
Linienphottransistoren mit Hilfe eines Tiefpassfilters.
Unterschreitet die Helligkeit schlagartig den tiefpassgefilterterten
Wert, wird ein Flag gesetzt.
Ausgabe:
testhell=0: keine Linie
Bit0= Linie links erkannt
Bit1= Linie rechts erkannt
Bit0+Bit1 Linie senkrecht
*************************************************************************/
uint8_t testhell()
{
uint8_t ergebnis=0;
uint16_t lineData[2];
LineData(lineData);
HellLinks=(HellLinks*TIEFPASS+lineData[0])/(TIEFPASS+1);
HellRechts=(HellRechts*TIEFPASS+lineData[1])/(TIEFPASS+1);
StatusLED(YELLOW);
if((lineData[0]+LIMIT)<(HellLinks)) ergebnis|=1;
if((lineData[1]+LIMIT)<(HellRechts)) ergebnis|=2;
void Msleep(int 10);
{
int z;
for(z=0;z<10;z++) Sleep(72);
}
return ergebnis;
}
int main(void)
{
int n;
Init();
StatusLED(RED);
FrontLED(ON);
// mittlere Helligkeit im Stand ermitteln
for(n=0;n<300;n++)
{
testhell();
}
StatusLED(YELLOW);
MotorDir(FWD,FWD);
MotorSpeed(150,150);
while(1)
{
n=testhell();
BackLED(n&0x01,n&0x02);
StatusLED(YELLOW);
if(n!=0) // Falls Linie erkannt, dann drehen und zurück
{
StatusLED(GREEN);
MotorDir(RWD,RWD);
MotorSpeed(150,100);
void Msleep(int 600);
{
int z;
for(z=0;z<600;z++) Sleep(72);
}
MotorDir(RWD,FWD);
MotorSpeed(200,200);
void Msleep(int 600);
{
int z;
for(z=0;z<600;z++) Sleep(72);
}
MotorDir(FWD,FWD);
MotorSpeed(150,150);
}
void Msleep(int 10)
{
int z;
for(z=0;z<10;z++) Sleep(72);
}
}
}
/***************************************************************************
*
* 2007 robo.fr (Nickname) , christoph(at)roboterclub-freiburg.de
*
***************************************************************************
* 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 version 2 of the License, *
* If you extend the program please maintain the list of authors. *
* ( if there is no real name, the nick name has to be mentioned )
* If you want to use this software for commercial purposes and you *
* don't want to make it open source, please contact the authors for *
* licensing. *
***************************************************************************/
Ich hoffe, es funzt jetzt.Code:#include "asuro.h"
#define LIMIT 20 // Helligkeitsveraenderung, bei der eine Linie detektiert wird
#define TIEFPASS 50 // grosser Wert=grosse Zeitkonstante
// globale Variablen
uint16_t HellLinks;
uint16_t HellRechts;
/*************************************************************************
uint8_t testhell()
testhell ermittelt die durchschnittliche Helligkeit der beiden
Linienphottransistoren mit Hilfe eines Tiefpassfilters.
Unterschreitet die Helligkeit schlagartig den tiefpassgefilterterten
Wert, wird ein Flag gesetzt.
Ausgabe:
testhell=0: keine Linie
Bit0= Linie links erkannt
Bit1= Linie rechts erkannt
Bit0+Bit1 Linie senkrecht
*************************************************************************/
void Msleep(int dauer)
{
int z;
for(z=0;z<dauer;z++) Sleep(72);
}
/*************************************************************************/
unsigned char testhell(void)
{
uint8_t ergebnis=0;
uint16_t lineData[2];
LineData(lineData);
HellLinks=(HellLinks*TIEFPASS+lineData[0])/(TIEFPASS+1);
HellRechts=(HellRechts*TIEFPASS+lineData[1])/(TIEFPASS+1);
StatusLED(YELLOW);
if((lineData[0]+LIMIT)<(HellLinks)) ergebnis|=1;
if((lineData[1]+LIMIT)<(HellRechts)) ergebnis|=2;
Msleep(10);
return ergebnis;
}
int main(void)
{
int n;
Init();
StatusLED(RED);
FrontLED(ON);
// mittlere Helligkeit im Stand ermitteln
for(n=0;n<300;n++)
{
testhell();
}
StatusLED(YELLOW);
MotorDir(FWD,FWD);
MotorSpeed(150,150);
while(1)
{
n=testhell();
BackLED(n&0x01,n&0x02);
StatusLED(YELLOW);
if(n!=0) // Falls Linie erkannt, dann drehen und zurück
{
StatusLED(GREEN);
MotorDir(RWD,RWD);
MotorSpeed(150,100);
Msleep(600);
MotorDir(RWD,FWD);
MotorSpeed(200,200);
Msleep(600);
MotorDir(FWD,FWD);
MotorSpeed(150,150);
}
Msleep(10);
}
return(0);
}
/***************************************************************************
*
* 2007 robo.fr (Nickname) , christoph(at)roboterclub-freiburg.de
*
***************************************************************************
* 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 version 2 of the License, *
* If you extend the program please maintain the list of authors. *
* ( if there is no real name, the nick name has to be mentioned )
* If you want to use this software for commercial purposes and you *
* don't want to make it open source, please contact the authors for *
* licensing. *
***************************************************************************/
mic
Danke es hat endlich funkionirt ich danke dir Für deine Große hilfe
Gruß
Chief 2
Hallo Chief2,
damit das Ganze etwas einfacher wird, habe ich an dieser Stelle ein HEX-File abgelegt, damit man die Abstandserkennung sofort ausprobieren kann.
Gruß,
robo
Hallo Robo.fr
Danke Für das Programm Ich werd es sofort ausprobieren
Gruß Chief 2
Hallo alle zusammen
ich hab mir so ein programm machen wollen das der asuro die becher aus dem ring schiebt abber das programm meldet immer den fehler:
"test.c:207:error:expectet Identifiter or '(' before '{' token"
wen ich es kompilieren möchete
Hir ist das ProgrammDie zeile wo angeblich der Fehler liegt ist mit einen/***<<<***/makiert
Code:#include "asuro.h"
#include <stdlib.h>
#define LIMIT 20 // Helligkeitsveraenderung, bei der eine Linie detektiert wird
#define TIEFPASS 50 // grosser Wert=grosse Zeitkonstante
// globale Variablen
uint16_t HellLinks;
uint16_t HellRechts;
void Msleep(int dauer)
{
int z;
for(z=0;z<dauer;z++) Sleep(72);
}
unsigned char testhell(void)
{
uint8_t ergebnis=0;
uint16_t lineData[2];
LineData(lineData);
HellLinks=(HellLinks*TIEFPASS+lineData[0])/(TIEFPASS+1);
HellRechts=(HellRechts*TIEFPASS+lineData[1])/(TIEFPASS+1);
StatusLED(YELLOW);
if((lineData[0]+LIMIT)<(HellLinks)) ergebnis|=1;
if((lineData[1]+LIMIT)<(HellRechts)) ergebnis|=2;
Msleep(10);
return ergebnis;
}
int main(void)
{
int n;
Init();
StatusLED(RED);
FrontLED(ON);
// mittlere Helligkeit im Stand ermitteln
for(n=0;n<300;n++)
{
testhell();
}
StatusLED(YELLOW);
MotorDir(FWD,FWD);
MotorSpeed(150,150);
while(1)
{
n=testhell();
BackLED(n&0x01,n&0x02);
StatusLED(YELLOW);
if(n!=0) // Falls Linie erkannt, dann drehen und zurück
{
StatusLED(GREEN);
MotorDir(RWD,RWD);
MotorSpeed(150,100);
Msleep(600);
MotorDir(RWD,FWD);
MotorSpeed(200,200);
Msleep(600);
MotorDir(FWD,FWD);
MotorSpeed(150,150);
}
Msleep(10);
}
return(0);
}
uint8_t objekt_sichtbar(uint8_t distance)
{
uint16_t j,z;
DDRD |= (1 << DDD1); // Port D1 als Ausgang
PORTD &= ~(1 << PD1); // PD1 auf LOW
OCR2 = 254-distance; // wenn OCR2=0xFE dann Objekt sehr nahe
z=0;
for(j=0;j<30;j++); // loop time: 5ms
{
if (PIND & (1 << PD0))z++;
Sleep(6); // 6*Sleep(6)=1ms
}
if (z>=29) return FALSE; // Objekt nicht gefunden
else return TRUE;
}
{
uint8_t k,n; /***<<<***/ /***<<<***/ /***<<<***/
k=255;
for(n=0;n<8;n++)
{
if (!objekt_sichtbar(n)) k=n; // solange kein Objekt, Distanz erhoehen
}
return k;
uint8_t n;
Init();
while(1)
{
n=abstand();
StatusLED(OFF);
BackLED(OFF,OFF);
if(n!=255)
{
if (n<6) MotorDir (FWD,FWD);MotorSpeed(220,220);
if (n<4) MotorDir (FWD,FWD);MotorSpeed(220,220);
if (n<3) MotorDir (FWD,FWD);MotorSpeed(220,220);
if (n<2) MotorDir (FWD,FWD);MotorSpeed(220,220);
Msleep(10);
}
}
}
habe deinen doppelpost entfernt. bitte nur einmal klicken und dann warten!!
du schliesst die funktion uint8_t objekt_sichtbar() mit einer schliessenden klammer }. danach öffnest du weider eine klammer { ohne einen funktionsnamen zu definieren.