RTC and Interval Timing

cattledog:

  // Sets fan interval

if ( minute >= 0 && minute < 10 )
  {
    digitalWrite ( RELAY2, HIGH );
  }
  else
  {
    digitalWrite ( RELAY2, LOW );
  }
  if ( minute >= 30 && minute < 35 )
  {
    digitalWrite ( RELAY2, HIGH );
  }
  else
  {
    digitalWrite ( RELAY2, LOW );
  }





It's not clear to me why this code did not work as you intended. I'm not sure if you had the correct syntax for reading the RTC, or if the relays were not connected properly or of the correct logic. You could add some serial debug commands to see what the actual value of minute going into our conditional tests.

You really do need to break your project into pieces. Can you make the relays operate correctly with digitalWrite() commands? Can you get the correct time from the RTC? Linking the two, or using the time library will not be difficult if you have all the pieces working on their own.

Would it be possible to rewrite the expression as follows?

if ( minute >= 0 && minute <10 ) || (minute >= 30 && minute < 40 );
{
  digitalWrite ( Relay2, HIGH);
}
else
{
  digitalWrite ( Relay2, LOW);
}

I would be using the "||" ("or") logic function.