also toleranzmäßig funkitoniert mehr oder weniger ist noch ne einstellungssache. Aber er braucht so lange, um die Sensoren für die linienverfolgung abzufragen. Kann man den Code "beschleunigen"?
Code:
#include "asuro.h"
#include <stdlib.h>
#define toleranz 20

void delay(int zlr);
void gerade();
void zuruck(int timezuruck);
void links(int timelinks);
void rechts(int timerechts);
void vor(int timevor);
void lk(int timelk);
void rt(int timert);
void taster();
void porsche();

unsigned char taste;
unsigned char PollSwitch(void);
unsigned int data[2];
unsigned int j=1;
/*Lenkung ist linker Motor
Rechts ist FWD
Links ist RWD

Antrieb ist rechter Motor
Vorfährts ist FWD
Rückfährts ist RWD
*/

int main(void)
{            
Init();
DDRD |= (1 << DDD1);   // Port D1 als Ausgang
PORTD &= ~(1 << PD1);   // PD1 auf LOW
    while (1)
  {
  FrontLED(ON);
  BackLED(ON,OFF);
  delay(500);
  BackLED(ON,ON);
  delay(500); 
  gerade();
  delay(1000);
  MotorDir(BREAK,BREAK);
  while (1)
  {
	if (PIND & (1 << PD0))
    {
		MotorSpeed(255,255);
		LineData(data);
		taste = PollSwitch();
		
		porsche();
	}
	  
	
	else
	{
		
		MotorSpeed(255,150);
		LineData(data);
		taste = PollSwitch();
		
		porsche();
	}
	}
  
  }
  return 0;
}

void delay (int zlr)
{
  unsigned int i;
  i = 1;
  while (i < zlr)         
  {
     Sleep (72);         
     i++;
  }
  return;
}

void gerade()
{
	MotorDir(FWD,BREAK);
	delay(1000);
	MotorDir(RWD,BREAK);
	delay(500);
}
 
void zuruck(int timezuruck)
{
	MotorDir(BREAK,RWD);
	delay(timezuruck);
}

void links(int timelinks)
{
	MotorDir(RWD,FWD);
	delay(timelinks);
}

void rechts(int timerechts)
{
	MotorDir(FWD,FWD);
	delay(timerechts);
}


void vor(int timevor)
{
	MotorDir(BREAK,FWD);
	delay(timevor);
}

void lk(int timelk)
{
	MotorDir(RWD,BREAK);
	delay(timelk);
}

void rt(int timert)
{
	MotorDir(FWD,BREAK);
	delay(timert);
}

void taster()
		{
		if (taste == 1) //Rechts vorne
			{
				gerade();
				zuruck(1000);
				links(500);
				vor(700);
				rechts(600);
				vor(500);
				rechts(400);
				links(1000);
				rechts(500);
			}
		if (taste == 2) //2te von Rechts vorne	
			{
				gerade();
				zuruck(1000);
				links(500);
				vor(700);
				rechts(600);
				vor(500);
				rechts(400);
				links(1000);
				rechts(500);
			}
			
		if (taste == 4) //Mitte vorne
			{
				gerade();
				zuruck(1500);
				MotorDir(BREAK,BREAK);
				delay(200);
				lk(500);
				vor(1500);
				rt(1000);
				zuruck(2500);
				lk(1000);
				vor(2500);
				rt(500);
			}
			
		if (taste == 7) //2te von Links vorne
			{
				gerade();
				zuruck(1000);
				rechts(500);
				vor(700);
				links(600);
				vor(500);
				links(400);
				rechts(1000);
				links(500);
			}
		if (taste == 16) //Links Vorne
			{
				gerade();
				zuruck(1000);
				rechts(500);
				vor(700);
				links(600);
				vor(500);
				links(400);
				rechts(1000);
				links(500);
			}
		if (taste == 31) //hinten
			{
				gerade();
				links(500);
				rechts(1000);
				links(1000);
				rechts(500);
			}
		}
  

void porsche()
  {
  		if (taste > 0)
			{
				taster();
			}
			
		else if(data[0]>(data[1]+toleranz))
			{
				links(500);
				BackLED(ON,OFF);
			}
			
		else if(data[0]<(data[1]-toleranz))
			
			{
				rechts(400);
				BackLED(OFF,ON);
			}
			
		else
			{
				vor(200);
				BackLED(ON,ON);
			} 
  }