//ICC-AVR application builder : 19.01.2006 16:06:09 // Target : M8 // Crystal: 1.0000Mhz #include #include #include unsigned int einer=0; unsigned int value=0, value2=0,x=0, value3=0; //16Bit groß #pragma interrupt_handler timer0_ovf_isr:10 void timer0_ovf_isr(void) { ACSR = 0x80; ADCSR = 0xEF; TCNT0 = 0x83; //reload counter value } #pragma interrupt_handler adc_isr:15 void adc_isr(void) { //conversion complete, read value (int) using... value=ADCL; //Read 8 low bits first (important) value|=((int)ADCH << 8); //read 2 high bits and shift into top byte //value=200; value2=((50*value)/1023); value3=((int)value2); einer=value3%10; // ausgabe(einer); } //################################################################## void ausgabe (int x) { switch (x) { case 0 : PORTD=0x00; break; case 1 : PORTD=0x01; break; case 2 : PORTD=0x10; break; case 3 : PORTD=0x11; break; case 4 : PORTD=0x08; break; case 5 : PORTD=0x09; break; case 6 : PORTD=0x18; break; case 7 : PORTD=0x19; break; case 8 : PORTD=0x02; break; case 9 : PORTD=0x03; break; default:; } } //+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ void main() { MCUCR = 0x00; GICR = 0x00; PORTC = 0x00; DDRC = 0x2E; PORTD = 0x00; DDRD = 0xFF; TCCR0 = 0x00; //stop TCNT0 = 0x83; //set count ADCSR = 0x00; //disable adc ADMUX = 0x00; //select adc input 0 TCCR0 = 0x03; //start timer TIMSK = 0x01; //timer0 overflow interrupt enable SEI(); while (1) { ausgabe(einer); } }