Re: HELP! Trouble using && operator with 3 conditi
you know this, single equal sign (=) used assignment, while double equal signs (==) used comparison.
long story . . .
in following code snippet, you're using assignment, should using comparison:
read "if val greater or equal pad0thresh , toggleaval assigned value low , togglebval assigned value low . . .".
this should read "if val greater or equal pad0thresh , toggleaval equal value low , togglebval equal value low . . .", written:
common mistake
(the value/variable on left of operator lvalue, while value/variable on right of operator rvalue)
long story . . .
in following code snippet, you're using assignment, should using comparison:
code: [select]
if(val >= pad0thresh && toggleaval = low && togglebval = low) read "if val greater or equal pad0thresh , toggleaval assigned value low , togglebval assigned value low . . .".
this should read "if val greater or equal pad0thresh , toggleaval equal value low , togglebval equal value low . . .", written:
code: [select]
if( val >= pad0thresh && toggleaval == low && togglebval == low)common mistake

(the value/variable on left of operator lvalue, while value/variable on right of operator rvalue)
code: [select]
lvalue = rvalue;
if( lvalue == rvalue )
thanks, johntron. would've missed = vs. == bit.
i figured out 3-condition boolean. needed more parentheses. (specifically, each term/condition needs enclosed own set , boolean argument enclosed in set.) nonfunctional lines like:
else if(val >= pad5thresh && toggleaval = high && togglebval = high)
...whereas fixed them , read (and compile properly) as:
else if((val >= pad5thresh) && (toggleaval == high) && (togglebval == high))
notice updated equals arguments. takes care of problem, compiler has gotten thru loop stage without issue, reaches midi/serial stage , has problem, i'll start new thread that.
cheers,
jake
i figured out 3-condition boolean. needed more parentheses. (specifically, each term/condition needs enclosed own set , boolean argument enclosed in set.) nonfunctional lines like:
else if(val >= pad5thresh && toggleaval = high && togglebval = high)
...whereas fixed them , read (and compile properly) as:
else if((val >= pad5thresh) && (toggleaval == high) && (togglebval == high))
notice updated equals arguments. takes care of problem, compiler has gotten thru loop stage without issue, reaches midi/serial stage , has problem, i'll start new thread that.
cheers,
jake
Arduino Forum > Forum 2005-2010 (read only) > Software > Syntax & Programs > Re: HELP! Trouble using && operator with 3 conditi
arduino
Comments
Post a Comment