Page 1 of 1

using temp probes for other code.

Posted: Tue May 29, 2012 8:49 pm
by Meshmez
how do i use the reading of temp probe 2 in a "if" statement like:

if (tempprobe2 <= 760)
{
do something
}

and while im posting... will this work to have moonlights on from the end of standardlights until 3am? basically i want to have the moonlights go off at 3am.

if ( hour() >= 20 && hour () <= 3 )
{
ReefAngel.MoonLights(Port2); // Moonlights or Refugium
}

Re: using temp probes for other code.

Posted: Tue May 29, 2012 8:57 pm
by rimai

Code: Select all

if (ReefAngel.Params.Temp[T2_PROBE]<= 760)
No, && means and. You will never have an hour that is both >=20 and <=3.
You need to use ||, which means or.

Code: Select all

  if ( hour() >= 20 && hour () <= 3 )
  {
    ReefAngel.MoonLights(Port2); // Moonlights or Refugium
  }
  else
  {
    ReefAngel.Relay.Off(Port2);
  }

Re: using temp probes for other code.

Posted: Tue May 29, 2012 8:58 pm
by rimai
For your reference:
http://arduino.cc/en/Reference/HomePage
Look for Boolean Operators

Re: using temp probes for other code.

Posted: Tue May 29, 2012 9:38 pm
by Meshmez
awesome!

Thanks for both posts!