 #define TEMP_ADC_PIN A3
 #define HEATER_PIN 8
 
-#define SAMPLE_DELAY_MS 1000L
-#define HEATER_PERIOD 10000L
-
-#define OPEN_LOOP_MODE
-//#define P_MODE
+#define SAMPLE_DELAY_MS 250L
+#define HEATER_PERIOD_MS 10000L
+#define PID_UPDATE_PERIOD_MS 125L
+
+//#define OPEN_LOOP_MODE
+#define P_MODE
+//#define I_MODE
 //#define PI_MODE
 //#define PD_MODE
 //#define PID_MODE
 
-#ifdef OPEN_LOOP_MODE
-#	define DUTY_INIT 0.5
-#else
 #	define DUTY_INIT 0.0
-#endif
-
-#define PGAIN 1000
+
+#define PGAIN 0.1
 #define IGAIN 0
 #define DGAIN 0
 #define IMIN 0
 #define IMAX 100
 
-#define TARGET 27
+#define TARGET 23.5 // 21.5C ambient + 23.5C rise = 45C target
 
 #define TEMP_TO_DUTY_SLOPE 0.1
 #define TEMP_TO_DUTY_OFFSET 0.0

	return ( sum * 0.0048828125 / (float)TEMPERATURE_DATA_POINT_COUNT - 0.5 ) * 100.0 + 5.0;
}

float tempChangeToDuty(float tempChange)
{
  return min(1.0, max(0.0, tempChange * TEMP_TO_DUTY_SLOPE + TEMP_TO_DUTY_OFFSET));

	if (heaterPeriodTimeLeft < 0)
	{
		heaterOn();
		heaterOnTime = millis() + (uint32_t)(heaterDutyCycle * HEATER_PERIOD_MS);
		heaterPeriodTime = millis() + HEATER_PERIOD_MS;
    
    DEBUG0(Serial.print(F("heaterOnTime - millis() = ")));
    DEBUG0(Serial.println(heaterOnTime - millis()));
