Advertisement
KRITSADA

MikroC PIC18F4550 with ADC show at LCD

May 8th, 2017
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.20 KB | None | 0 0
  1. // LCD module connections
  2. sbit LCD_RS at RE1_bit;
  3. sbit LCD_EN at RE2_bit;
  4. sbit LCD_D4 at RD4_bit;
  5. sbit LCD_D5 at RD5_bit;
  6. sbit LCD_D6 at RD6_bit;
  7. sbit LCD_D7 at RD7_bit;
  8.  
  9. sbit LCD_RS_Direction at TRISE1_bit;
  10. sbit LCD_EN_Direction at TRISE2_bit;
  11. sbit LCD_D4_Direction at TRISD4_bit;
  12. sbit LCD_D5_Direction at TRISD5_bit;
  13. sbit LCD_D6_Direction at TRISD6_bit;
  14. sbit LCD_D7_Direction at TRISD7_bit;
  15. // End LCD module connections
  16.  
  17. char txt[6];
  18. int ad;
  19. void main(){
  20.   ADCON1 |=0x09;
  21.   Lcd_Init();                        // Initialize LCD
  22.   Lcd_Cmd(_LCD_CLEAR);               // Clear display
  23.   Lcd_Cmd(_LCD_CURSOR_OFF);          // Cursor off
  24.   lcd_Out(1,1,"LLLLLL");
  25.   while(1){
  26.     ad=ADC_Read(0);
  27.     WordToStr(ad,txt);
  28.     Lcd_Out(2,1,txt);                 // Write text in first row
  29.     Delay_ms(200);
  30.     ad=ADC_Read(3);
  31.     WordToStr(ad,txt);
  32.     Lcd_Out(2,9,txt);                 // Write text in first row
  33.     Delay_ms(200);
  34.     ad=ADC_Read(4);
  35.     WordToStr(ad,txt);
  36.     Lcd_Out(1,1,txt);                 // Write text in first row
  37.     Delay_ms(200);
  38.     ad=ADC_Read(5);
  39.     WordToStr(ad,txt);
  40.     Lcd_Out(1,9,txt);                 // Write text in first row
  41.     Delay_ms(200);
  42.  
  43.   }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement