Advertisement
bartek27210

kjl

Jun 5th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.14 KB | None | 0 0
  1. #include "reg515.sfr"
  2. #include "lcd.h"
  3.  
  4.  
  5. int main()
  6. {
  7.     int kod=0,delta=0;
  8.     unsigned char cos;
  9.     CRCH=0xFF;
  10.     CRCL=0x00;
  11.     CCH1=0xFF;
  12.     CCL1=0;
  13.     CCEN=0x08;
  14.     CLK=1;
  15.     P3=0xDF;
  16.     T2I0=1;
  17.     T2R1=1;
  18.     lcd_init();
  19.     out_instr(1);
  20.     out_char('P');
  21.     out_char('W');
  22.     out_char('M');
  23.     out_char('=');
  24.     out_char('0');
  25.     out_char('0');
  26.     out_char('0');
  27.     while(1)
  28.     {
  29.         int i=0;
  30.         cos=get_kb();
  31.         for(i=0;i<4000;i++);
  32.         if(cos=='d')
  33.         {
  34.             if(CCL1<1);
  35.             else
  36.             {
  37.                 CCL1--;
  38.                 delta=100*CCL1/255;
  39.                 out_instr(1);
  40.                 out_char('P');
  41.                 out_char('W');
  42.                 out_char('M');
  43.                 out_char('=');
  44.                 out_char((int)delta/100+48);
  45.                 if(delta<100)
  46.                     out_char((int)delta/10+48);
  47.                 else
  48.                     out_char((int)delta/10+38);
  49.                 out_char((int)delta%10+48);
  50.  
  51.             }
  52.         }
  53.         if(cos=='g')
  54.         {
  55.             if(CCL1>254);
  56.             else
  57.             {
  58.                 CCL1++;
  59.                 delta=100*CCL1/255;
  60.                 out_instr(1);
  61.                 out_char('P');
  62.                 out_char('W');
  63.                 out_char('M');
  64.                 out_char('=');
  65.                 out_char((int)delta/100+48);
  66.                 if(delta<100)
  67.                     out_char((int)delta/10+48);
  68.                 else
  69.                     out_char((int)delta/10+38);
  70.                 out_char((int)delta%10+48);
  71.             }
  72.         }  
  73.     }
  74.     return 1;
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement