Ive got some code I converted from a 18F4550 thermostat, want to use it on a 16F688, on running the RA4 port never goes high, and the LCD displays a block on row1 about location 14 on a 4x20 LCD. adjusting the pot on RA0 does nothing, ive tried messing with ADCON0 & 1, and ANSEL, but im doing something wrong.
MCP9700A on RA1
POT on RA0
RA4 has LED
Code:include "ADC_Default.bas" DEFINE LCD_DREG PORTC ' LCD Data bits on PORTC DEFINE LCD_DBIT 2 ' PORTC starting address DEFINE LCD_RSREG PORTC ' LCD RS bit on PORTC DEFINE LCD_RSBIT 0 ' LCD RS bit address DEFINE LCD_EREG PORTC ' LCD E bit on PORTC DEFINE LCD_EBIT 1 ' LCD E bit address DEFINE LCD_BITS 4 ' LCD in 4-bit mode DEFINE LCD_LINES 4 ' LCD has 4 rows ANSEL = %00000011 TRISA = %00000011 TRISC = 0 ' PORTC is output LCDOUT $FE, 1 ' Clear LCD PAUSE 500 ' Wait 0.5sec for LCD to initialize SETT Var Word ' A/D converter result in 10bit READT var word AGAIN: ADCIN 0, READT ' Read Channel 0 data ADCIN 1, SETT ' Read Channel 0 data ReadT = ReadT - 6500 SETT = SETT / 1024 'Output = 0 - 63 readT = ((((readT / 10) * 9) / 5) / 13) + 32 'Convert ANA0 to Farent. setT = sett + 40 ' Temp Range will be 40 - 103 LCDOUT $FE, 2 LCDOUT $FE, $80 LCDOUT "Set Temp = ", DEC setT , $DF , "F " LCDOUT $FE, $C0 LCDOUT "Temp = ", DEC READT , $DF , "F " if SETT < (readt - 1) then PORTA.4 = 0 if sett > (readt + 1) then PORTA.4 = 1 pause 100 GOTO AGAIN ' Repeat END





Bookmarks