Kann dies bitte mal jemand detailliert erklären, wie es hier durch Setzen der Register TCCR2, OCR2 und TIMSK zu 36 kHz kommt.

Code:
/* Timer2, zum Betrieb mit der seriellen Schnittstelle, fuer die IR-Kommunikation auf 36 kHz eingestellt. */
   TCCR2  = (1 << WGM20) | (1 << WGM21) | (1 << COM20) | (1 << COM21) | (1 << CS20);
   OCR2   = 0x91;           // duty cycle fuer 36kHz
   TIMSK |= (1 << TOIE2);   // 36kHz counter
Das gleiche bitte für die Ultraschall-Funktion mit 40 kHz:
Code:
   // Change Oscillator-frequency of Timer 2
   // to 40kHz, no toggling of IO-pin:
   TCCR2  = (1 << WGM21) | (1 << CS20);
   OCR2   = 100;              // 40kHz @8MHz crystal
   TIMSK |= (1 << OCIE2);     // OCIE2:  Timer/Counter2 Output Compare Match Interrupt Enable