Hi good morning everyone,
i have a little project on PIC16F88 whit LM35.
When temperature go over Tmax Portb.6 go High.


I don't understand how to compare values


On the lCD display i have 3 value
Temp from Lm35
Tmax from eprom
Tmin from eprom


but i don't undesrstand why portb.6 go always High also if the temperature Tmax is low


thank you

the code is


temp var word
temperature var word
samples var word
sample VAR BYTE
quanta con 1250
Tmax VAR byte
Tmin VAR byte


Read 0,DatoEE
Tmin=DatoEE


Read 1,DatoEE
Tmax=DatoEE


temp = 0 'Clear temp register
temperature = 0 'Clear temperature register
sample = 0 'Clear sample register
samples = 0 'Clear samples register


FOR sample = 1 TO 20 'Take 20 samples
ADCIN 0, temp 'Read AN0 into temp variable
samples = samples + temp
PAUSE 50 ' Wait 1/4 seconds per reading
NEXT sample
temp = samples/20 'Average over 20 samples (Every 5 seconds)
temperature= (temp*10) */ quanta


Pause 200 ' Timeout for LCD to settle
LCDOUT $FE, 1 ' cancella LCD
LCDOUT $FE, 2 ' ritorna al primo carattere
lcdout $FE, 2, "Temp ",dec2 (temperature/100),".", dec1 (temperature//100),$DF,"C"
lcdout $FE, $C0, "Tmin ",#Tmin DIG 1,#Tmin Dig 0," Tmax ",#Tmax DIG 1,#Tmax Dig 0






If temperature > Tmax then
PORTA.6=1
Endif