#include #include #include #include unsigned char lcd_digits[10] __attribute__((progmem)) = {0x3f, 0x06, 0x5b, 0x4f, 0x66, 0x6d, 0x7d, 0x07, 0x7f, 0x6f}; unsigned char key; unsigned char data[4]={2,0,0,8}; unsigned mode=0; void actual_data(unsigned int ad) { data[3]=ad%10; data[2]=(ad/10)%10; data[1]=(ad/100)%10; data[0]=(ad/1000)%10; } ISR(ADC_vect) { if(mode==0) actual_data(ADC); } ISR(TIMER0_COMP_vect) { static unsigned char num=0; PORTC=(PORTC&0xf0)|1<>4)|0xf0; if(k==0xff) { p=0; return; } if(p==1) return; _delay_ms(10); if(k!=((PINC>>4)|0xf0)) return; p=1; key=~k; } void menu(void) { static unsigned int wynik=0; switch(key) { case 1: if(mode==0) mode=1; else mode=0; break; case 2: wynik+=ADC; break; case 4: wynik-=ADC; break; case 8: wynik=0; break; } key=0; if(mode==1) actual_data(wynik); } int main(void) { DDRB=0xff; DDRC=0x0f; PORTC|=0xf0; TCCR0=0x0c; OCR0=0x40; TIMSK|=1<