I suspect that this statement doesn't work.
Can anyone comment?
if (Sw[6]||Sw[0]||TF == 2) {return;} // if button 0 or 6 is pressed or if TF=2: return
I suspect that this statement doesn't work.
Can anyone comment?
if (Sw[6]||Sw[0]||TF == 2) {return;} // if button 0 or 6 is pressed or if TF=2: return
You could well be right, but with just that to go on, it's difficult to tell. What is Sw[] an array of? How is it populated?
Does
if (Sw[6]||Sw[0]||(TF == 2)) {return;}
make a difference ?
It shouldn't. The equivalence operator has higher precedence than logical or. It never hurts to try it though, and I would probably have written it that way anyway, just for reading comprehension.
I suspect that this statement doesn't work.
Can anyone comment?
What are you expecting it to do? It does not mean if Sw[6] or Sw[0] or TF is 0 do something, if that is what you were expecting.
I expect it simply to return if one of the conditions is met.
As for the array: it's an array of booleans expressing if a certain button was pressed or not.
Post the whole sketch.
try replacing your line with this
if (digitalRead(6)||digitalRead(0)||TF == 2) {return;}
If it works, there is something wrong in the rest of your code.
I think I would have written as discrete compares:
if ( (Sw[6]==2) || (Sw[0] ==2) ||(TF == 2) ) {return;}
I don't think that is what the OP is after:
// if button 0 or 6 is pressed or if TF=2
In which case, some expression involving "digitalRead (sw[0])" etc, perhaps?
Which is why the OP should post the whole sketch, rather than us all speculating on what they meant.
No disagreement here
If Sw are boolean arrays then should it not be
if ( (Sw[6]==true) || (Sw[0] ==true) ||(TF == 2) ) {return;}
Yes I know you can shorten this to:-
if ( (Sw[6]) || (Sw[0]) ||(TF == 2) ) {return;}
What the OP needs to do is to print out the variable values before the if, and he will find that the statement is doing what it should do.
The whole sketch is several pages A4. I don't think this will help.
The array Sw[i] holds the boolean value of 9 buttons after a ReadButtons: true if pressed, false if not.
The if statement works for the Sw-values but I doubt if the third or-condition is evaluated by the statement.
Of course I can try by splitting the statement in two but thought you would know.
I don't think this will help.
I think you're not going to get much help unless you do post.
What's with the italics?
The whole sketch is several pages A4.
It's a good job you found this fault before it got too big.
thought you wiseguys
I always thought "wiseguy" had pejorative connotations.
What's with the italics?
Sw[i], I reckon.
Sw*, I reckon.[/quote]*
Fixed. 8)
Thanks for all your help.
Perhaps I should rephrase the question: Can I put multiple conditions in one if statement?