Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <reg515.sfr>
- #include <lcd.h>
- float e1=0, e2=0, e3=0,y=0,y1=0;
- int wartosc=40,wart;
- float a=1.15,b=-1.25,c=0.12;
- unsigned char znak = '\0';
- unsigned char memo= '\0';
- unsigned int ciag = 0;
- unsigned int flaga = 1;
- unsigned int ifEnter = 0;
- int f;
- void main()
- {
- IEN0=0x88;
- TMOD=160;
- TR1=1;
- T2CON=0x10;
- T2I0=0x01;
- CCEN=0x08;
- CRCH=0xFF;
- CRCL=0;
- TH2=0xFF;
- TL2=0;
- CCH1=0xFF;
- CLK=0x01;
- P3=0xDF;
- lcd_init();
- out_instr(0x01);
- out_char('4');
- out_char('0');
- while(1)
- {
- znak = get_kb();
- if(znak=='\0')
- memo=znak;
- if (memo!=znak) {
- if((znak >='0') && (znak<='9'))
- {
- if(flaga==1){
- out_instr(0x01);
- flaga=0;}
- out_char(znak);
- memo = znak;
- ciag = ciag*10 + ((int)znak -48);
- ifEnter = 0;
- }
- else if(znak == 'e' && ifEnter == 0) {
- flaga=1;
- memo = znak;
- f=ciag;
- wartosc=f;
- ciag = 0;
- ifEnter = 1;
- }
- }
- }
- _interrupt 3 void kom(void)
- {
- DAPR=8;
- while(BSY!=0)
- {
- }
- wart=ADDAT;
- e1=wartosc-wart;
- y=y1+a*e3+b*e2+c*e1;
- e2=e1;
- e3=e2;
- y1=y;
- if(y<0)
- {y=0;}
- if(y>255)
- {y=255;}
- CCL1=(int)y;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement