program PIC16F887_LCD_003
dim LCD_RS as sbit at RC4_bit
LCD_EN as sbit at RC5_bit
LCD_D4 as sbit at RC0_bit
LCD_D5 as sbit at RC1_bit
LCD_D6 as sbit at RC2_bit
LCD_D7 as sbit at RC3_bit
LCD_RS_Direction as sbit at TRISC4_bit
LCD_EN_Direction as sbit at TRISC5_bit
LCD_D4_Direction as sbit at TRISC0_bit
LCD_D5_Direction as sbit at TRISC1_bit
LCD_D6_Direction as sbit at TRISC2_bit
LCD_D7_Direction as sbit at TRISC3_bit
dim counter as word
dim counter_txt as string[5]
main:
PORTC = 0xFF
TRISC = 0x00
ANSELC = 0x00
OSCCON = %01110010
ANSELA = %00000001
TRISA = %00111111
ADCON0 = %00000001
ADCON1 = %10000000
Lcd_Init() Lcd_Cmd(_LCD_CLEAR) Lcd_Cmd(_LCD_CURSOR_OFF) while TRUE counter = ADC_Read(0)
WordToStr(counter, counter_txt)
Lcd_Out(2,1,counter_txt)
WordToStr(ADRESH, counter_txt)
Lcd_Out(1,1,counter_txt)
WordToStr(ADRESL, counter_txt)
Lcd_Out(1,8,counter_txt)
WordToStr(ADRESH*256+ADRESL, counter_txt)
Lcd_Out(2,8,counter_txt)
delay_ms(100)
wend
end.