Hi
I am trying to turn off port 4 on my relay if either of the ATO floats IsActive
I tired the following code but the second ato in the list takes precedence. If i put High in first them low works as expected and if low is first the high works. I am guessing that I need to add something else but i cant find what.
if (ReefAngel.HighATO.IsActive())
{
ReefAngel.Relay.On(Port4);
}
else
{
ReefAngel.Relay.Off(Port4);
}
if (ReefAngel.LowATO.IsActive())
{
ReefAngel.Relay.On(Port4);
}
else
{
ReefAngel.Relay.Off(Port4);
}
I would also like to have port4 only turn on after 60-120 seconads after the ato float returns to the "active" state.
thanks
Andy
Using both High and Low ATO to turn off port
Re: Using both High and Low ATO to turn off port
Sorry for the late reply, if i am understanding you want to have port4 on after either ato has been active for 60s. You can try the code below
adjust the activation delay to your liking
//Place in globals
//Place in void loop
adjust the activation delay to your liking
//Place in globals
Code: Select all
unsigned long highATOActiveTime = 0;
unsigned long lowATOActiveTime = 0;
const unsigned long activationDelay = 60000; // 60 seconds delay
Code: Select all
if (ReefAngel.HighATO.IsActive()) {
if (highATOActiveTime == 0) {
highATOActiveTime = millis(); // Start the timer if High ATO is active
}
} else {
highATOActiveTime = 0; // Reset the timer if High ATO is inactive
}
// Check Low ATO state
if (ReefAngel.LowATO.IsActive()) {
if (lowATOActiveTime == 0) {
lowATOActiveTime = millis(); // Start the timer if Low ATO is active
}
} else {
lowATOActiveTime = 0; // Reset the timer if Low ATO is inactive
}
// Determine if either ATO has been active for at least 60 seconds
if ((highATOActiveTime != 0 && millis() - highATOActiveTime >= activationDelay) ||
(lowATOActiveTime != 0 && millis() - lowATOActiveTime >= activationDelay)) {
ReefAngel.Relay.On(Port4); // Turn on Port 4 if either ATO is active for 60 seconds
} else {
ReefAngel.Relay.Off(Port4); // Turn off Port 4 if neither ATO is active for 60 seconds
}
Sincerely, Brennyn