PID Temperature Controller for Peltier Cells

What i want to do?
I want to control the current through peltier cell beyond a certain set point temperature(spt).I have a mosfet driver circuit for that.In this code my spt is 30.When temp goes below 30 i want the current through the peltier cell to be zero.However in this code the reverse is happening,ie current is passing when temp goes below 30degree.How do i fix this???The code is attached…If any editing is required plz send the edited code.

PID_1st_try.ino (2.98 KB)


Please see #6 of the second thread linked above.

Why don't you read the documentation for the PID library.

The last argument to the constructor is wrong in your code.