If Else statement command assistance

Need some help if possible on coding. Trying to get a pump to turn on if ANY of the 4 "valve" conditions are met.

if (valve1VCC=HIGH)||(valve2VCC=HIGH)||(valve3VCC=HIGH)||(valve4VCC=HIGH) {
} else {

= for assignment, == for comparison.


Beware of accidentally using the single equal sign (e.g. if (x = 10) ). The single equal sign is the assignment operator, and sets x to 10 (puts the value 10 into the variable x). Instead use the double equal sign (e.g. if (x == 10) ), which is the comparison operator, and tests whether x is equal to 10 or not. The latter statement is only true if x equals 10, but the former statement will always be true.

This is because C evaluates the statement if (x=10) as follows: 10 is assigned to x (remember that the single equal sign is the assignment operator), so x now contains 10. Then the 'if' conditional evaluates 10, which always evaluates to TRUE, since any non-zero number evaluates to TRUE. Consequently, if (x = 10) will always evaluate to TRUE, which is not the desired result when using an 'if' statement. Additionally, the variable x will be set to 10, which is also not a desired action.

From if - Arduino Reference

if (valve1VCC=HIGH)||(valve2VCC=HIGH)||(valve3VCC=HIGH)||(valve4VCC=HIGH){

The way that your parenthesis are is not right.

is all outside the if.

if (valve1VCC == HIGH || valve2VCC == HIGH || valve3VCC == HIGH || valve4VCC == HIGH)

makes more sense. Note the spaces. They cost nothing and make the code easier to read.

Also, there is a pair of parentheses missing.

Also, when it is tempting to use numbers in variable names, it is time to learn about arrays.

Also, please post code using code tags.

Also, please post the entire program and not just snippets.

Got it working. TY for input.