some help with using millis

i want to add a millis delay of 5 minutes after a pin goes low from a temp sensor but can’t figure it out or where to put it here is the piece of code.also need when heater goes low this is to stop short cycling any help would be much appreciate

if ( temp_f > coolOnTemp)
digitalWrite (ChillerPin,HIGH);}


if ( temp_f < heatOnTemp)
digitalWrite (HeaterPin,HIGH);}
else{ digitalWrite(HeaterPin,LOW);}

I am confused. You wrote “…millis delay…” but millis() and delay(…) are two different things.
Furthermore, you didn’t explain what it is that you want to have happen after 5 minutes.

I can’t help this way, and I don’t know if anyone else will help until:

(1) ALL of the code is posted, not just a snippet, AND
(2) The code is formatted using CTRL-T in the IDE, AND
(3) The code is properly posted using the </> button, AND
(4) You explain what you REALLY want to do.

By the way, delay(…) is evil and should be avoided for most things, especially when it comes to a five minute delay.

All variables used with millis() should be declared as unsigned long, and only subtraction should be used.
In general:
(A) When something interesting happens, save the current time using millis().
(B) Each time through loop(), check if the then-current time minus the delay time is greater than or equal to the saved time. If so, do whatever.

Good Luck!

You need something called hysteresis, not a delay. You don't turn the heat off until the temperature exceeds the set point by a small amount. You don't turn cooling until you have gotten somewhat below the desired cutoff temperature.

what i would like is to keep the chiller pin and heater pin low for five minutes if it goes low and then go back to high after 5 minutes not sure if i used ctrl-t right and my code is to long to post

 if ( temp_f > coolOnTemp)
    digitalWrite (ChillerPin, HIGH);

  else {
    digitalWrite (ChillerPin, LOW);

  if ( temp_f < heatOnTemp)
    digitalWrite (HeaterPin, HIGH);
  else {
    digitalWrite (HeaterPin, LOW);


Since you're still only going to show a piece of the code, here's a piece of the answer.

When an action happens, record the value of millis in a variable. On each pass of the loop, subtract that from the current value from millis to see how long it has been since that thing happened. If it has been longer than 5 minutes then you can do whatever other action.

Where you need to put that in this particular program is anyone's guess. Right now you're the only one with the information (the rest of the code) to figure that out.

If it is true that "...this is to stop short cycling..." then PaulS has the right answer with "...hysteresis...".

Delta_G has a good answer too, and is struggling with the same issue that I had.

richl15 should listen to them.

The demo Several Things at a Time illustrates the use of millis() to manage timing.