Thermostat code

  fine=((30*analogRead(5))/1024); //calculating the desired temp.

Integer arithmetic will drive you crazy, until you figure out that that is the problem, and deal with it.

Embedding function calls in statements like this makes it very difficult to troubleshoot. As you've been able to print other values, you should have been able to print the potentiometer reading, except that it is embedded in the math.

Isolate both calls to analogRead(), storing the value read, and then print that value. Does turning the potentiometer actually affect the reading of the temperature sensor? It shouldn't.