/********************************************* Project : timer Version : v1.0 Date : 11/25/2007 Author : R.Shiri Company : tsd Comments: this timer powered on after afew secounds that adjasted by user Chip type : ATmega16 Program type : Application Clock frequency : 8.000000 MHz Memory model : Small External SRAM size : 0 Data Stack size : 256 *********************************************/ #include #include #include #include #asm .equ __lcd_port=0x1B #endasm void main(void) { int count=0, loop=0; int start=0; char display[16]; PORTA=0x08; DDRA=0x08; PORTD=0x00; DDRD=0x40; lcd_init(16); while (1) { delay_ms(100); loop++; if(PIND.2==1&&start==0) { delay_ms(100); if(PIND.2==1&&start==0) PORTD.6=0; count=count+10; } if(PIND.3==1&&start==0) { delay_ms(25); if(PIND.3==1&&start==0) start=1; } if(start==1&&loop%5==0) { count--; } delay_ms(100); lcd_clear(); sprintf(display," %i S to on ",count); lcd_puts(display); lcd_gotoxy(0,1); lcd_putsf(" amin farhodi "); if(start==1&&count==0) { PORTD.6=1; start=0; } }; }