I’m currently tying myself up in knots trying to do time context aware signalling.
I’d like to (for example) turn an LED on if it’s between 9am and 11am AND a software flag is set to 1.
I’d like to (for example) FLASH that LED if it’s between 12 and 1pm AND a software flag isn’t set to 1.
I’d like to (for example) turn that same LED off if it’s between 9am and 11am AND a software flag ISN’T set to 1.
I’d like to (for example) turn an LED off if it’s between 4pm and 5pm AND a software flag is set to 1.
How would you approach this? I am currently doing this sort of thing, and it’s VERY difficult for me to read and predict how the LED will actually behave as my “if nests” are for me not intuitive to build and interpret.
if (Time.hour() == 17 )
{
greenLED.on();
redLED.off();
}
else if (Time.hour() >= 18 || Time.hour() < 7)
{
redLED.on();
greenLED.off();
}
else if (Time.hour() >= 7 && Time.hour() < 9)
{
greenLED.on();
redLED.off();
}
else
{
redLED.off();
greenLED.off();
}
Thanks