Thanks for the reply Mark

The problem with my code is that as soon as the input falls below the upper temperature setting, it switches off...

Rather I want it to wait until it falls below the lower setting - here is my full code - maybe that will explain things.

Code:
Define  LCD_DREG        PORTD 
Define  LCD_DBIT        4 
Define  LCD_RSREG       PORTE 
Define  LCD_RSBIT       0 
Define  LCD_EREG        PORTE 
Define  LCD_EBIT        1 
TRISA = %00001011 
trisd = %00000000 
temp        var     byte                        'temp variable 
        ADCON1 = 4                              ' Set PortA 0, 1, 3 to A/D inputs 
        Low PORTE.2                             ' LCD R/W line low (W) 
        Pause 100                               ' Wait for LCD to start 
mainloop: 
        ADCON0 = $41                            ' Set A/D to Fosc/8, Channel 0, On 
        Pauseus 50                              ' Wait for channel to setup                                      
        ADCON0.2 = 1                            ' Start conversion 
        Pauseus 50                              ' Wait for conversion 
        temp = ADRESH                           ' ADC output address = Temp 
        Lcdout $fe, 1, "Water Temp = ", #temp,"'F" ' Send to LCD 
        if temp >= 80 then gosub fan1on         ' fan ON at 80 
        If temp <> 70 then gosub fan1off        ' fan OFF at 70 
        Pause   100                             ' Sample 10 times a second 
        Goto    mainloop                        ' Repeat 
        End                                                     

        Return 
fan1on 
        portd.0 = 1 
        lcdout $fe,$94, "Fan 1 ON" 
        return 
fan1off 
        portd.0 = 0 
        return
I hope you can help..

Can't wait until I can afford the full PicBasic and then I can get stuck into putting this all together - being a broke student sucks.


Hoops