Der Code sieht jetzt folgendermaßen aus:
Code:
int main(void){

  uint16_t hell = 500; 
  
  PORTD = 0x00;            //PORTD alle Pins low 
  DDRD = 0x30;            //PORTD Pin 4 und 5 als Ausgang 
  
  TCCR1A = (1<<WGM10) | (1<<WGM11) |(1<<COM1A1);     //10 Bit Phase Correct PWM, max Wert 0x03FF 
  TCCR1B = (1<<CS10) | (1<<CS11);                  //Takt = CPU-Takt/8 
  
  OCR1A = hell;         //Vergleichswert
  
  while(1){ 
    DDRB = 0x00;      //Port B alle Pins Eingang 

    if ((PINB & (0x10))==0)         //Wenn Taster 1 gedrück (Pin 2 auf low) 
   { 
      if (hell < 0x03F6) 
      { 
       hell = hell +10;                  //Erhöhe Helligkeit um 10
       OCR1A=hell;	   
       _delay_ms(1);                           //Verzögerung 
      } 
   } 
    if ((PINB & (0x20))==0)         //Wenn Taster 2 gedrück (Pin 3 auf low) 
   { 
      if (hell > 0x0009) 
      { 
       hell= hell -10;                  //Verringere Helligkeit um 10
	   OCR1A=hell;
       _delay_ms(1);                           //Verzögerung 
      } 
   }
}