/***************************************************** Project : pwm Version : 1.0 Date : 9/21/2007 Author : rasool shiri Company : tarahane sazeheye digital web : kuservice.blogfa.com tel : 09188319189 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 #asm .equ __lcd_port=0x1B ;PORTA #endasm #include void main(void) { char display[16]; int set=1; PORTA=0x08; DDRA=0x08; PORTD=0x00; DDRD=0x20; TCCR1A=0x81; TCCR1B=0x01; TCNT1H=0x00; TCNT1L=0x00; ICR1H=0x00; ICR1L=0x00; OCR1AH=0x00; OCR1AL=0xa0; OCR1BH=0x00; OCR1BL=0x00; lcd_init(16); while (1) { delay_ms(150); if(PIND.2==1) { delay_ms(100); if(PIND.2==1) OCR1AL=OCR1AL-5; set=1; } if(PIND.3==1&&OCR1AL!=255) { delay_ms(100); if(PIND.3==1) OCR1AL=OCR1AL+5; set=1; } if (OCR1AL<115) OCR1AL=115; if(set==1) { lcd_clear(); sprintf(display,"speed index: %i",OCR1AL); lcd_puts(display); lcd_gotoxy(0,1); lcd_putsf("Jafari && Babaei"); set=0; } }; }