Try this...don't know if it'll work or not, but it should put a value on your LCD that matches the A/D result register, assuming you have something wired to PortA.0, like the wiper of a pot, with +5v on one side and ground on the other...
Code:@ DEVICE pic16F877 @ DEVICE pic16F877, WDT_on @ DEVICE pic16F877, PWRT_ON @ DEVICE pic16F877, PROTECT_OFF @ DEVICE pic16F877, HS_OSC DEFINE LCD_DREG PORTB DEFINE LCD_DBIT 0 DEFINE LCD_RSREG PORTE DEFINE LCD_RSBIT 1 DEFINE LCD_EREG PORTE DEFINE LCD_EBIT 0 DEFINE LCD_RWREG PORTE DEFINE LCD_RWBIT 2 DEFINE LCD_BITS 8 DEFINE LCD_LINES 2 DEFINE LCD_COMMANDUS 1000 DEFINE LCD_DATAUS 225 raw var word : trisa=1 : trisb=0 : trise=0 : adcon0 = $c1 : adcon1 = $ce main: adcon0.2 = 1 'start A/D conversion wait_for_it: if adcon0.2 = 1 then wait_for_it 'wait for A/D to finish raw.highbyte = adresh : raw.lowbyte = adresl lcdout $fe , 1 , DEC4 raw : goto main END




Bookmarks