#include #include #include #include typedef unsigned char u08; #define ADC_VREF_TYPE 0xA0 volatile u08 einer=0b1000000, zehner=0b1000000; u08 count=0,count1=0; u08 umschalt=0; u08 i; int data; int dataADC; int maximum; int minimum; int x; // Timer 0 overflow interrupt service routine ISR(SIG_OVERFLOW0) { if (umschalt==0) { PORTB &= ~(1 << 3); // Bit 3 in PORTB wird geloescht PORTB |= (1 << 4); // Bit 4 in PORTB wird gesetzt umschalt = 1; PORTA = zehner; } else { PORTB &= ~(1 << 4); // Bit 4 in PORTB wird geloescht PORTB |= (1 << 3); // Bit 3 in PORTB wird gesetzt umschalt=0; PORTA = einer; } } // of the AD conversion result ad wandler 10 u08 read_adc(u08 adc_input) { ADMUX=adc_input|ADC_VREF_TYPE; dataADC=0x00; // Start the AD conversion-Mittelwert aus 4 Wandlungen for(i=0;i<4;i++) { ADCSR|=0x40; // Wait for the AD conversion to complete while ((ADCSR & 0x10)==0); //auf Abschluss der Konvertierung warten dataADC += (ADCW>>7); //Wandlungsergebnisse aufaddieren ADCSR|=0x10; //ADC deaktivieren } dataADC /= 4; //Summe dur vier teilen 0 arithm. Mittelwert return dataADC; } void delay_loop( u08 dauer ) { u08 i, j, k; for (i=0; i<255; i++) /* outer delay loop */ for (j=0; j<255; j++) /* outer delay loop */ for(k=0; kmaximum) maximum=data; if(data