Hallo Osser!

Da hast du natürlich Recht, aber is ja auch gleich Feierabend, da is man mit den Gedanken schon mal wo anders... \/

Hier unser Quelltext:

Code:
#include "asuro.h"
void LocalInit(void)
{
TCCR2 = (1 << WGM21) | (1 << CS20);
OCR2  = 0x64;
ADCSRA = 0x00;
ACSR = 0x02;
ADMUX=0x03;

SFIOR|=(1<<ACME);
DDRD&=~(1<<6);
}

void Ping(unsigned char length)
{
int count72kHz=0;
TCCR2 = (1 << WGM21) | (1 << COM20) | (1 << CS20);
while (count72kHz<length)
	{
	OCR2=0x64+length/2-count72kHz;
	}
TCCR2 = (1 <<WGM21) | (1 << CS20);
OCR2=0x64;
}

int main(void)
{
int pos,i ;
int posmarker;
Init();
LocalInit();
while(1)
	{
	posmarker=0;
	Ping(20);
	for (pos=0; pos<100; pos++)
		{
		Sleep(10);
		if ((ACSR& (1<<ACI))!=0)
			{
			if (posmarker==0)
				{
				posmarker=pos;
				}
			}
		ACSR|=(1<<ACI);
		}
	if(posmarker>10)
		{
		StatusLED(GREEN);
		MotorDir(FWD,FWD);
		MotorSpeed(200,200);
		}
	else
		{
		StatusLED(RED);
		MotorDir(FWD,RWD);
		MotorSpeed(0,200);
		for (i=0; i<100; i++)
			{
			Sleep(200);
			}
		}
	}
	return 0;
}