Need some help with a code

I'm trying to maintain temperature in my brewing system. Right now I'm using a code that says

if(Fahrenheit < 150 )
digitalWrite(heat, HIGH)
else
digitalWrite(heat, LOW);

When it hits 150 a timer needs to start so it stays at 150 for an hour. After an hour it needs to go up to a different temperature (220). And then stay at that for an hour.

Any ideas?
Thanks

You need to save the value of millis() when the temperature reaches 150 and then keep checking the time until the 60 minutes (3,600,000 msecs) has elapsed

if (millis() - savedMillis >= 3600000UL) {
    // time to change the temperature.
}

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

If you are only interested in longer time intervals you could create a variable (called seconds ?) which is upldated from millis() but makes the timing calcs more obvious. For example

seconds = millis() / 1000;
if (seconds - savedSeconds >= 3600) {
    // time to change the temperature
}

Use unsigned long variables for everything connected with millis()

...R

This is not a difficult task. Most members want an attempt at the program to be made before they will get involved.

Show us you have tried and we will help improve or suggest changes.

Weedpharma

Robin2:
You need to save the value of millis() when the temperature reaches 150 and then keep checking the time until the 60 minutes (3,600,000 msecs) has elapsed

if (millis() - savedMillis >= 3600000UL) {

// time to change the temperature.
}




The demo [Several Things at a Time](http://forum.arduino.cc/index.php?topic=223286.0) illustrates the use of millis() for timing.

If you are only interested in longer time intervals you could create a variable (called seconds ?) which is upldated from millis() but makes the timing calcs more obvious. For example


seconds = millis() / 1000;






if (seconds - savedSeconds >= 3600) {
    // time to change the temperature
}






Use unsigned long variables for everything connected with millis()

...R

Thanks, I'll be trying this tonight and let you know what I did.