Re: HELP! Trouble using && operator with 3 conditi

You probably know this, but a single equal sign (=) is used for assignment, while double equal signs (==) is used for comparison.

Long story . . .

In the following code snippet, you're using assignment, but you should be using comparison:

if(val >= pad0Thresh && toggleAVal = LOW && toggleBVal = LOW)

Read "if val greater than or equal to pad0Thresh and toggleAVal is assigned the value LOW and toggleBVal is assigned the value LOW . . .".

This should read "if val greater than or equal to pad0Thresh and toggleAVal is equal to value LOW and toggleBVal is equal to value LOW . . .", which is written:

if( val >= pad0Thresh && toggleAVal == LOW && toggleBVal == LOW)

Common mistake :)

(the value/variable on the left of the operator is the lvalue, while the value/variable on the right of the operator is rvalue)

lvalue = rvalue;
if( lvalue == rvalue )

Thanks, JohnTron. I would've missed the = vs. == bit.

I figured out the 3-condition boolean. I just needed more parentheses. (Specifically, each term/condition needs to be enclosed by its own set and then the boolean argument itself is enclosed in a set.) The nonfunctional lines look like: else if(val >= pad5Thresh && toggleAVal = HIGH && toggleBVal = HIGH) ...whereas I fixed them and they now read (and compile properly) as: else if((val >= pad5Thresh) && (toggleAVal == HIGH) && (toggleBVal == HIGH))

Notice the updated equals arguments. So that takes care of that problem, but now that the compiler has gotten thru the loop stage without issue, it reaches the MIDI/serial stage and has a problem, but I'll start a new thread for that.

Cheers,

Jake

Cool, glad I could help.

Also, because of operator precedence, you only need the outer set of parentheses. The comparison operators are evaluated first, followed by the boolean operators. It's all personal preference though. If the extra parentheses make the code more readable, then go for it :)

http://processing.org/learning/examples/operatorprecedence.html