The following link is to the completeC/C++ code implemented using the Arduino IDE.
Complete Temperature Control C/C++ Code
The Following Link is to the PID Controller Function that is part of the Complete Temperature Control C/C++ Code
Function Declaration
float PID_output(float process, float setpoint, float Prop, float Integ, float deriv, int Interval, bool action)
Function Call
contOutNorm=PID_output(C_Variable/500, heaterSetting/500,propBand, integralTime, derivativeTime, 1000, controlAction);
The C_Variable which is the filtered temperature sensor, and the heaterSetting which is the Set Point generated by the Set Point potentiometer are normalized 0.0 to 1.0 by dividing the 2 variables by 500, the full temerature range corresponding to maximum voltage at the analog input to the Nano microcontroller. The LM35 sensor will only generate a voltage of 0 to 1.4 Volts corrsponding to 0 to 140 deg C, but the analog input is 0 to 5V which corresponds to 0 to 500 deg C.

The diagram above illustrates the steps that occur in implementing a PID algorithm digitally. The first block and the final block are done outside of the PID function.
The following function declaration, part of the Compete Temperature C/C++ code, is used for filtering the Temperature Sensor.
float TR_C_filterFunction(float timeConstant, float processGain,float blockIn, float intervalTime);
The following function call is for the above filtering function.
TR_C_Filtered=TR_C_filterFunction(5, 1.0,TR_C, 1000); //filter time constant is first argument in seconds
The basic logic for a difference equation method 1st order filter is:
blockOut=blockOut +(intervalTime/1000/(timeConstant+intervalTime/1000))*(processGain*blockIn-blockOut);