Ich habe jetzt das Program editiert aber es will immer noch nicht klappen jetzt leuchtet die LED dauerhaft:
Code:
 /*
  * SMARTINIUS.c
  *
  * Created: 26.07.2011 00:17:22
  *  Author: Martinius
  */ 
 #define F_CPU 16000000
 #include <avr/io.h>
 #include <util/delay.h>
 #include <avr/interrupt.h> 
 
 const int FWD = 1; // Definition der Richtungswerte
const int STOP = 0;
const int BWD = 2;
const int ON = 1; //andere Werte
const int OFF = 0;
const int Left = 2;
const int Right = 1;
const int Enable = 1;
const int Disable = 0;
const int Reset = 2;
const float A = 11.925;
const float BL = 0.660;
const float BR = 0.610;
const float ADCconst = 00.04883;
 
 void Setup(void){ // Stellt den Controller für das nachfolgende Programm ein
                     // muss immer als erstes aufgerufen werden.
 DDRC |= (1<<PC7); // Status LED
 DDRB |= (1<<PB0); // IR_Eable
 DDRA &= ~(1<<PA0); // IR_Left
 DDRA &= ~(1<<PA1); // IR_Right
 ADMUX |= (1<<REFS0);//Reverrenzspannungsquelle des ADC wird festgelegt
 ADCSRA = (1<<ADPS1) | (1<<ADPS2);     // Frequenzvorteiler
 ADCSRA |= (1<<ADEN);                  // ADC aktivieren
 ADCSRA |= (1<<ADSC);                  // eine ADC-Wandlung
 while (ADCSRA & (1<<ADSC) ) {}        // auf Abschluss der Konvertierung warten 
 }
 
 void Status_LED(uint8_t Status){
 if(Status == 1){
 PORTC |= (1<<PC7);
 }
 if(Status == 0){
 PORTC &= ~(1<<PC7);
 }
 }
 uint16_t get_Ir_Distance (uint8_t Dir){ // Distance in mm
 if(Dir==1){//Right
   float x;
   ADMUX = (ADMUX & ~(0x1F)) | (1 & 0x1F);
   ADCSRA |= (1<<ADSC);            // eine Wandlung "single conversion"
   while (ADCSRA & (1<<ADSC) ) {}  // auf Abschluss der Konvertierung warten
   x = ADCW;
   x = x*ADCconst;
   x = x-BL;
   x = A/x;
   x = x*10
   return x;                    // ADC auslesen und zurückgeben
 }
 
 if(Dir==2){//Left
   float x;
   ADMUX = (ADMUX & ~(0x1F)) | (0 & 0x1F);
   ADCSRA |= (1<<ADSC);            // eine Wandlung "single conversion"
   while (ADCSRA & (1<<ADSC) ) {}  // auf Abschluss der Konvertierung warten
   x = ADCW;
   x = x*ADCconst;
   x = x-BL;
   x = A/x;
   x = x*10;
   return x;
   
 }
return 0;
 }
 void Ir_Enable(uint8_t Status){
 if (Status == 1){
 PORTB |= (1<<PB0);
 }
 if(Status == 0){
 PORTB &= ~(1<<PB0);
 }
 }
 int main(void)
 {
 Setup();
 
 Ir_Enable(ON);
 
     while(1){
     drive_ahead();
     if(get_Ir_Distance(Right)<2000){
     Status_LED(ON);
     }
     if(get_Ir_Distance(Left)< 2000){
     Status_LED(ON);
     }
     }
 }