try this
Code:
<code><font color="#000000"> <font color="#000080">DEFINE </font>LCD_DREG PORTD <font color="#008000">'data register
</font><font color="#000080">DEFINE </font>LCD_RSREG PORTE <font color="#008000">'register select
</font><font color="#000080">DEFINE </font>LCD_RSBIT 0 <font color="#008000">'pin number
</font><font color="#000080">DEFINE </font>LCD_EREG PORTE <font color="#008000">'enable register
</font><font color="#000080">DEFINE </font>LCD_EBIT 1 <font color="#008000">'enable bit
</font><font color="#000080">DEFINE </font>LCD_RWREG PORTE <font color="#008000">'read/write register
</font><font color="#000080">DEFINE </font>LCD_RWBIT 2 <font color="#008000">'read/write bit
</font><font color="#000080">DEFINE </font>LCD_BITS 8 <font color="#008000">'width of data
</font><font color="#000080">DEFINE </font>LCD_LINES 2 <font color="#008000">'lines in display
</font><font color="#000080">DEFINE </font>LCD_COMMANDUS 2000 <font color="#008000">'delay in micro seconds
</font><font color="#000080">DEFINE </font>LCD_DATAUS 20 <font color="#008000">'delay in micro seconds
'Set the port directions. We are setting PORTA.0 to an input, all rest outputs
'all of PORTD is set to outputs to run the LCD
'and all of PORTE as outputs even though PORTE has only 3 lines.
</font>TRISA = %11111111 <font color="#008000">'set PORTA lines
</font>TRISD = %00000000 <font color="#008000">'set all PORTD lines to output
</font>TRISE = %00000000 <font color="#008000">'set all PORTE lines to output
</font> <font color="#008000">'Set the Analog to Digital control register
</font>ADCON1=%10000010 <font color="#008000">'see discussion above
' added
' -----
</font>TRISB = %00001111 <font color="#008000">'PORTB<3:0> = input
</font> <font color="#008000">' others to output
</font>OPTION_REG.7=0 <font color="#008000">' ENABLE INTERNAL PULL-UPS
' -----
'Define the variables used
</font>ADVAL <font color="#000080">VAR</font> <font color="#000080">BYTE</font> <font color="#008000">'Create ADVAL to store result
</font>TEMP <font color="#000080">VAR</font> <font color="#000080">BYTE</font> <font color="#008000">'temperature Farenheit variable
</font>TEMPC <font color="#000080">VAR</font> <font color="#000080">BYTE</font> <font color="#008000">'temperature Celsius variable
</font>DEG <font color="#000080">CON </font>223 <font color="#008000">'write an degree mark on lcd
</font>Mode <font color="#000080">VAR BIT
</font>C <font color="#000080">CON </font>1
F <font color="#000080">CON </font>0
<font color="#008000">'define the adcin parameters
</font><font color="#000080">DEFINE</font> ADC_BITS 10 <font color="#008000">'Set number of bits in result
</font><font color="#000080">DEFINE</font> ADC_CLOCK 3 <font color="#008000">'Set clock source (3=rc)
</font><font color="#000080">DEFINE</font> ADC_SAMPLEUS 50 <font color="#008000">'Set sampling time in uS
</font><font color="#000080">PAUSE </font>500
<font color="#000080">LCDOUT </font>$FE, 1 <font color="#008000">'clear screen
</font>PORTB.4=0
Mode = C
LOOP: <font color="#008000">'The main loop of the program
</font><font color="#000080">ADCIN </font>4, ADVAL <font color="#008000">'Read channel 0 to adval
</font>ADVAL =(ADVAL*/500)>>2
TEMP=ADVAL
TEMPC=((TEMP-32) *100) /180
<font color="#000080">IF </font>PORTB.0=0 <font color="#000080">THEN
</font>Mode = Mode ^ 1
<font color="#000080">WHILE </font>PORTB.0 = 0 : <font color="#000080">WEND
PAUSE </font>50
<font color="#000080">ENDIF
PAUSE </font>200
<font color="#000080">LCDOUT </font>$FE, 1,"Temp="
<font color="#000080">IF </font>Mode=F <font color="#000080">THEN
LCDOUT DEC3 </font>TEMP,DEG, "F" <font color="#008000">'print to line 1 of 2 line display
</font><font color="#000080">ELSE
LCDOUT DEC3 </font>TEMPC,DEG, "C"
<font color="#000080">ENDIF
GOTO </font>LOOP
<font color="#000080">END
</font></code>
sure a INT0 interrupt would have it's own advantages as well. Begin with it.
Bookmarks