|
LINK/ANTILINK (Selector)
I apologize if this is simple to do but I'm having a little trouble with it. Basically, I want a selector to choose between 4 fan settings (Off, Low, Med, High). I tried doing this with variables and logic, but I'm having a few issues.
I have 3 button images and 3 digital outputs corresponding to the 3 speeds. The button images set to trigger output works fine. Trying to have the button images change variables can work, but if I do it this way, the button images do not reflect the status changes in the outputs. Also, I can't seem to get more than one THEN statement to fire per each function. For example:
If(fan_var == 1){
fan_low = on;
fan_med = off;
fan_high = off;
}
This won't work for me. It will only trigger the first statement. I have to set it up like:
if(fan_var == 1){
fan_low = on;
}
if(fan_var == 1){
fan_med = off;
}
if(fan_var == 1){
fan_high = off;
}
Doing it this way, the button images won't change with the outputs. I have tried doing it with just boolean logic based on the outputs, like:
if(fan_low == true){
fan_med = false;
}
if(fan_low == true){
fan_high = false;
}
The button images seem to work this way, but the issue here is that it doesn't like it when the state changes because the next setting will be true before the previous setting is turned off.
Anyway, sorry if this is confusing. Basically, I'm looking for a break-before-make selector where the button images (primary/secondary) will reflect the changes made to their respective digital outputs. Like:
//if off, turn others off, then turn on
if(fan_low.downclick == true && fan_low.output == false){
fan_med.output = false;
fan_med.display_button = secondary;
fan_high.output = false
fan_high.display_button = secondary;
fan_low.output = true;
fan_low.display_button = primary;
}
//if on, turn off
if(fan_low.downclick == true && fan_low.output == true){
fan_low.output = false;
fan_low.display_button = secondary;
}
Thanks for any help or insight you guys can bring.
|