Code:
int redLight = 0;
int whiteLight = 0;
void updateLights()
{
int combinedLights;
combinedLights = (redLight << 1) + whiteLight;
switch (combinedLights)
{
case 0:
myRelay.set(Relay.Value.kOff); // M+ and M- = 0V (Both Off)
break;
case 1:
myRelay.set(Relay.Value.kForward); // M+ = 12V, M- = 0V (White Only)
break;
case 2:
myRelay.set(Relay.Value.kReverse); // M+ = 0V, M- = 12V (Red Only)
break;
case 3:
myRelay.set(Relay.Value.kOn); // M+ = 12V, M- = 12V (Both On)
break;
}
}
Something like the above will give you two independent variables representing the lights that you can change without knowing the state of the other light. Just call updateLights periodically.
__________________
In life, what you give, you keep. What you fail to give, you lose forever...