#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}; ISR(TIMER0_COMP_vect) { static unsigned char num=0; PORTB=(PORTB&0xf0)|1<>4)|0xf0; if(k==0xff) { p=0; return; } if(p==1) return; _delay_ms(10); if(k!=((PINB>>4)|0xf0)) return; p=1; key=~k; } void menu(void) { static unsigned char pos=0; switch(key) { case 1: if(pos>0) pos--; break; case 2: if(pos<3) pos++; break; case 4: if(data[pos]<9) data[pos]++; break; case 8: if(data[pos]>0) data[pos]--; break; } key=0; } int main(void) { DDRA=0xff; DDRB=0x0f; PORTB|=0xf0; TCCR0=0x0c; OCR0=0x40; TIMSK|=1<