If statement combine comparison operators

Hi,

the following statement doesn't seem to work for me:
if (MotorDisable == false && (drive=='L' || drive=='R') && encRight < waytogo)

I just want to know if my syntax is wrong or something in the rest of my sketch's logic.

I want:

  • MotorDisable to be false
  • drive to be L or R
  • encRgight smaler than waytogo

Thanks
Robert

Try adding more brackets:

if ( (MotorDisable == false) && ((drive=='L') || (drive=='R')) && (encRight < waytogo) )

Post your code - maybe you've got a misplaced semicolon.

Thanks majenko,

this doesn't work either. Tomorrow I'll check if it's the statement of if the worblem lies somewhere else.

Thanks
Robert

or you could just post your code

try adding serial prints of the data before the compare, see if your conditions actually exist.

It worked with the extra brackets. But the error was erlier in the code. With the extrad Serial.prints it showed that I never reached this statement.
Thanks for the help.