Advertisement
Guest User

Untitled

a guest
May 20th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.77 KB | None | 0 0
  1. #include "reg515.sfr"
  2. #include "lcd.h"
  3.    
  4.  
  5.  
  6. int t = 0;
  7. int limp = 0;
  8.  
  9. void main()
  10. {
  11.  
  12.  
  13.     char x;
  14.     int j = 0;           
  15.     int wynik=0;   
  16.     int k=0;
  17.     int l_j, l_d, l_s; 
  18.  
  19.  
  20.     CRCH=0xFF;
  21.     CRCL=0x00;
  22.     CCH1=0xFF;
  23.     CCEN=0x08;
  24.     CLK=1;
  25.     P3=0xDF;
  26.     CCL1=50;
  27.     T2CON = 0x11;
  28.     lcd_init();
  29.  
  30.  
  31.     while(1)
  32.     {  
  33.     x = get_kb();
  34.     wynik = (100 * CCL1)/255;
  35.      l_j = wynik % 10;
  36.      if(wynik != 100)
  37.      l_d = wynik / 10;
  38.      else
  39.      l_d = 0;
  40.     l_s = wynik/ 100;
  41.     out_instr(0x01);
  42.     out_char(l_s+48);
  43.     out_char(l_d+48);
  44.    
  45.     out_char(l_j+48);
  46.     out_char('%');
  47.                                                                                                                        
  48.        
  49.            
  50.  
  51.         if(x=='g')
  52.         {
  53.             if(CCL1<255)
  54.                 CCL1 = CCL1+ 1;
  55.         }
  56.  
  57.         if(x=='d')
  58.         {
  59.           if(CCL1>0)
  60.                 CCL1 = CCL1 - 1;
  61.         }
  62.                            
  63.         for(j=0; j<2000;j++);  
  64.     }
  65.  
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement