Port toggle for driver reset

Do you have a question on how to do something.
Ask in here.
Post Reply
tyson_mitchell_88
Posts: 80
Joined: Thu Nov 05, 2015 2:45 pm
Location: Australia

Port toggle for driver reset

Post 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);
  }
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Port toggle for driver reset

Post 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.
tyson_mitchell_88
Posts: 80
Joined: Thu Nov 05, 2015 2:45 pm
Location: Australia

Re: Port toggle for driver reset

Post 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 );
  }
Image
User avatar
cosmith71
Posts: 1437
Joined: Fri Mar 29, 2013 3:51 pm
Location: Oklahoma City

Re: Port toggle for driver reset

Post 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
tyson_mitchell_88
Posts: 80
Joined: Thu Nov 05, 2015 2:45 pm
Location: Australia

Re: Port toggle for driver reset

Post by tyson_mitchell_88 »

Yep changing it to the second way. Should of thought of it from the start lol. Thanks mate
Image
Post Reply