Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <lcd.h>
- #include <reg515.sfr>
- int wart=40, wart2;
- float e1=0, e2=0, e3=0, y=0, y1=0;
- _interrupt 3 void przerwanie(void);
- int k=0, n;
- int main()
- {
- unsigned char znak='\0', poprz;
- int wynik=0, i, e=1;
- lcd_init();
- out_instr(0x1);
- T2R1=0x1;
- T2I0=0x1;
- CCEN=0x8;
- CRCH=0xFF;
- CRCL=0x0;
- TH2=0xFF;
- TL2=0x0;
- CCH1=0xFF;
- TMOD=0x10;
- IEN0=0x88;
- TR1=0x1;
- CLK=0x1;
- P3=0xDF;
- out_char('4');
- out_char('0');
- while (1)
- {
- poprz = znak;
- znak = get_kb();
- if (znak != '\0')
- {
- if(znak!=poprz)
- {
- if (znak>='0' && znak<='9')
- {
- if (e == 1)
- {
- out_instr(0x1);
- e = 0;
- }
- out_char(znak);
- wynik = wynik * 10 + ((int)znak - 48);
- }
- if (znak == 'e' && e==0)
- {
- wart = wynik;
- e = 1;
- wynik = 0;
- }
- for (i = 0; i < 20000; i++);
- }
- }
- }
- }
- _interrupt 3 void przerwanie(void)
- {
- DAPR=8;
- while(BSY!=0)
- {}
- wart2=ADDAT;
- e1=wart-wart2;
- y=y1+1.2*e1-1.05*e2+0.15*e3;
- e3=e2;
- e2=e1;
- y1=y;
- if(y<0)
- CCL1=0;
- if(y>255)
- CCL1=255;
- CCL1=(int)y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement