OK, I certainly don't understand what's going on. I am using a LM34CZ (if someone has a more precise temp sensor please let me know) and I am simply trying to read the voltage from it. It wasn't working correctly so I put a potentiometer on the analog port instead of it and that doesn't work either.

Below is the code.......someone please tell me what I am doing wrong. This code was actually taken from Bruce at Rentron.com. It is erratic but also the difference is +13 volts at some points. I have 2.55 on porta.3 and the input from the pot is on porta.1. I am using a 16F876.



DEFINE osc 20 ' We're using a 20 MHz oscillator
DEFINE ADC_BITS 8 ' Set A/D for 8-bit operation
DEFINE ADC_CLOCK 1 ' Set A/D clock Fosc/8
DEFINE ADC_SAMPLEUS 50 ' Set A/D sampling time @ 50 uS
samples VAR WORD ' Multiple A/D sample accumulator
sample VAR BYTE ' Holds number of samples to take
temp VAR BYTE ' Temperature storage
samples = 0 ' Clear samples accumulator on power-up

TRISA = %11111111 ' Set PORTA to all input
ADCON1 = %00000011 ' Set PORTA.0,1,2,5 = A/D, PortA.3 = +Vref
PAUSE 500 ' Wait .5 second

loop:
FOR sample = 1 TO 20 ' Take 20 samples
ADCIN 1, temp ' Read channel 0 into temp variable
samples = samples + temp ' Accumulate 20 samples
PAUSE 250 ' Wait approximately 1/4 seconds per loop
NEXT sample
temp = samples/20
DEBUG "Temperature is: ",DEC temp," Deg F",10,13
samples = 0 ' Clear old sample accumulator
GOTO loop ' Do it forever

END