Ich hab jetz das programm geändert dass es jetz irgendwo hinzu gehört abber es gibt dan neue probleme das ganze sieht jetz so aus
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 abstand()
{                           /***<<<***/                     /***<<<***/                        /***<<<***/
	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);
		}
	}
}
und die fehlermeldung jetz so:
test.c:106:error:redeclaration of 'n' with no linkage
test.c:97:errorrevious declaration of 'n' was here