Hi all. I am building a control for a freezer. I need to start the freezer at the specified temp and shut off when that is satisfied. (I have that) What I'm having trouble with is, I need to have the compressor stay off for 3 minutes before starting again. This is a single stage freezer getting down to -50 F. It gets above the specified temp before 3 minutes and causes the compressor to attempt to come on and lock up. What I need, I think, is a way to override the if statement reading the probe, so the loop will not run until the 3 minutes have elapsed, without stopping the display from reading the temp. Thanks for any help.
Here is the code I'm currently using, sorry can't get it in the code window for some reason.
#include <elapsedMillis.h>
#include <OneWire.h>
#include <DallasTemperature.h>
// Data wire is plugged into pin 2 on the Arduino
#define ONE_WIRE_BUS 3
#define ct 5
// Setup a oneWire instance to communicate with any OneWire devices
// (not just Maxim/Dallas temperature ICs)
OneWire oneWire(ONE_WIRE_BUS);
// Pass our oneWire reference to Dallas Temperature.
DallasTemperature sensors(&oneWire);
int offtime=1500;
void setup(void)
{ pinMode(ct, OUTPUT);
// start serial port
Serial.begin(9600);
Serial.println(" ColdTrap");
elapsedMillis elapsedTime; // used by elapsedmilis example
// Globally scoped - see comment above
unsigned long off = millis(); // used by millis() example...
unsigned int interval = 1000;
// Start up the library
sensors.begin();
}
void loop(void)
{ delay (offtime);
// call sensors.requestTemperatures() to issue a global temperature
// request to all devices on the bus
Serial.print(" ");
sensors.requestTemperatures(); // Send the command to get temperatures
Serial.println(" ");
Serial.print(" ");
Serial.print(sensors.getTempFByIndex(0)); // Why "byIndex"?
// You can have more than one IC on the same bus.
// 0 refers to the first IC on the wire
{
elapsedMillis (off);
{ if(sensors.getTempFByIndex(0) >= -50)
digitalWrite (ct, HIGH);
else
digitalWrite (ct, LOW);
do (ct,LOW);
while (off);
// I know this is wrong, this is just the latest attempt
}}}