Try this:
Code:INTCON = 0 ' NO INTERRUPT ADCON1 = %10001110 ' ADCON0 = %000101 'Disable Converter Module ANSEL = %00000001 'Disable Inputs Tranne AN0 OSCCON = %01100000 'Internal RC set to 4MHZ CMCON = 7 TRISA = %10001111 ' impostazioni INP/OUT TRISB = %00000000 ' delle porte '---------------------------------------------------- temp var word temperature var word samples var word sample VAR BYTE quanta con 1250 Tmax VAR byte Tmin VAR byte Tmin=16 Tmax=30 temp = 0 'Clear temp register temperature = 0 'Clear temperature register sample = 1 'Clear sample register samples = 0 'Clear samples register PORTA.6=0 do samples=0 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/1000 > Tmax then PORTA.6=1 else PORTA.6=0 Endif loop





Bookmarks