Advertisement
aprsc7

MicroC

Jan 27th, 2021
749
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.85 KB | None | 0 0
  1. // Lcd pinout settings
  2. sbit LCD_RS at RB4_bit;
  3. sbit LCD_EN at RB5_bit;
  4. sbit LCD_D7 at RB3_bit;
  5. sbit LCD_D6 at RB2_bit;
  6. sbit LCD_D5 at RB1_bit;
  7. sbit LCD_D4 at RB0_bit;
  8.  
  9. // Pin direction
  10. sbit LCD_RS_Direction at TRISB4_bit;
  11. sbit LCD_EN_Direction at TRISB5_bit;
  12. sbit LCD_D7_Direction at TRISB3_bit;
  13. sbit LCD_D6_Direction at TRISB2_bit;
  14. sbit LCD_D5_Direction at TRISB1_bit;
  15. sbit LCD_D4_Direction at TRISB0_bit;
  16.  
  17. int input;
  18.  
  19. char txt1[10];
  20. char txt2[10];
  21.  
  22. void main()
  23. {
  24.     ADCON1 = 0x80; //0b10000000
  25.     TRISA = 0xFF;
  26.     TRISC = 0;
  27.     TRISD = 0;
  28.  
  29.     Lcd_Init();
  30.     Lcd_Cmd(_LCD_CURSOR_OFF);
  31.  
  32.     while(1)
  33.     {
  34.         input = ADC_Read(0);
  35.  
  36.         IntToStr((input*5/1023.0)*1000, txt1);
  37.         Lcd_Out(1,1,txt1); Lcd_Out(1,8,"mV");
  38.  
  39.         IntToStr((input/1023.0)*100, txt2);
  40.         Lcd_Out(2,1,txt2); Lcd_Out(2,8,"%");
  41.     }
  42. }
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement