Temporize is posible?

Hello!

Anyone knows how to temporize an action? I want that if a temperature is less then "x" to do something (just some digital outs) but no more than "y" minutes. How could I do this?
Thank you!

Lots of ways to do that. Some better than others.

if(temp < x)
{
   digitalWrite(somePin, HIGH);
   delay(y * 60 * 1000UL);
      digitalWrite(somePin, LOW);
}

is one way. Not a very good one.

if(someTime == 0)
{
   if(temp < x)
   {
      digitalWrite(somePin, HIGH);
      someTime = millis();
   }
}

if(millis() - someTime > y * 60 * 1000UL)
{
   digitalWrite(somePin, LOW);
   someTime = 0;
}

is another way that is more responsive..

There is the TimeAlarm library, too, that provides a third way. Turn the pin on, set an alarm, with callback. When called back, turn the pin off.

Thank you!
I'll study how TimeAlarm library works.
The solution with delay() is the worst! This means that the program is "stuck" there for a long time and can't "read" what temperature I have. The solution with "milis()" looks fine, but I have 2 questions:
I. What does "1000UL" mean??
II. Could I use, in the same sketch, more then one interval independently?

I. What does "1000UL" mean??

The 1000 part should be pretty obvious. There are 1000 milliseconds in a second. The UL on the end tells the compiler to treat the value as an unsigned long. Without that, the 60 * 1000 part would be stored in an int sized register, which would overflow. With it, the 60 * 1000 result is stored in a long register, which is the proper size.

II. Could I use, in the same sketch, more then one interval independently?

Absolutely.

Ok!
Thank you very much Paul!