Quote:
|
Originally Posted by stephenthe1
um, would this code cause two pistons to fire assuming they are hooked up to relay 1 and relay2. also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.
Code:
if (p1_sw_trig = 1) {
|
Needs to be:
Code:
if (p1_sw_trig == 1) {
And what Mike is referring to is that the check for p2_sw_trig will override any values you set after checking p1_sw_trig.
I assume you are looking for one button push to be forward and another to be reverse, and neutral if no button is pushed?
Just as an example, you could combine the checks on the neutral condition to make sure they don't override any other button push, e.g.,
Code:
if (p1_sw_trig == 0 && p2_sw_trig == 0) {
relay1_fwd = 0;
relay1_rev = 0;
relay2_fwd = 0;
relay2_rev = 0;
}
The p2 button will still override the p1 button if both are pushed at the same time.
Quote:
|
Originally Posted by stephenthe1
also, you'll notice in my if statements that I used if its 1, then to execute the stuff, is that the right way of asking if the switch is one, or should I do (p2_sw_trig01), I've seen that but didn't know what it meant. what's the correct way? thanks.
|
"if (p2_sw_trig01)" is treated the same as "if (p2_sw_trig01 == 1)"
[edit] Fixed my typo. (and I'm trying to be a good example). This is why you get other people to check your code. Thanks, Dave.