Page 1 of 1

Port toggle for driver reset

Posted: Sat Jan 23, 2016 2:27 am
by tyson_mitchell_88
Hi,

I need to flick a port off and on again. Thought something like this but I'm not sure if I'm remotely right.

Code: Select all

//White off 

  if (hour()==18 && minute()==30 && second()>=0 && hour()==18 && minute()==30 && second()<2)
  {
    ReefAngel.Relay.Off(Port8);
  } else {
    ReefAngel.Relay.On(Port8);
  }
Or is it just

Code: Select all

//White off 

  if (hour()==18 && minute()==30 && second()==0)
  {
    ReefAngel.Relay.Off(Port8);
  } else {
    ReefAngel.Relay.On(Port8);
  }

Re: Port toggle for driver reset

Posted: Sat Jan 23, 2016 4:53 am
by cosmith71
Either of those should work. I'd go with the first one just because it has a little more delay.

Be aware that except for those two seconds, that port will ALWAYS be on with that code. You would also need to place it after any other code that controls that port.

Re: Port toggle for driver reset

Posted: Sat Jan 23, 2016 5:32 am
by tyson_mitchell_88
So if I go with this it should just turn off for those 2 sec. Otherwise will be on 500 > 2100.

Thanks Colin

Code: Select all

//White off 

  if (hour()==18 && minute()==30 && second()>=0 && hour()==18 && minute()==30 && second()<2)
  {
    ReefAngel.Relay.Off(Port8);
  } else {
    ReefAngel.StandardLights( Port8,5,00,21,00 );
  }

Re: Port toggle for driver reset

Posted: Sat Jan 23, 2016 5:41 am
by cosmith71
There are a couple of ways.

You can do it the way you have posted.

You can do this, too.

Code: Select all

//White off 

  if (hour()==18 && minute()==30 && second()<2)
  {
    ReefAngel.Relay.Off(Port8);
  } else {
    ReefAngel.StandardLights( Port8,5,00,21,00 );
  }
You could also have the StandardLights up higher in your loop() and leave out the else completely.

Code: Select all

 loop()
  
  ReefAngel.Standardlights( Port8,5,0,21,0);
  .
  .
  .
  .
  .
  .
  .
  if (hour()==18 && minute()==30 && second()<2)
  {
    ReefAngel.Relay.Off(Port8);
  }
--Colin

Re: Port toggle for driver reset

Posted: Sat Jan 23, 2016 5:52 am
by tyson_mitchell_88
Yep changing it to the second way. Should of thought of it from the start lol. Thanks mate