digitalRead question

hi there I have this code what works fine

if ((FalSafeValue < 359 && (failFlag == false)) {

but I would like to add a diditalRead in this.I have had a go in the code below but now that piece of the code doesn't seem to work at all now.

if ((FalSafeValue < 359) ll !digitalRead(tempFalSafe) && (failFlag == false)) {

what have I done wrong?

The logical OR operator is ||

yes sorry it is ||
any other ideas?

My crystal ball says your problem is on line 28.

You need to do two things:

  1. Elaborate. "It doesn't work" is not helpful. What do you expect to happen? What actually happens?

  2. Post all of your code, along with a schematic of what's attached where.

Use more () to enforce the order of evaluation is probably part of the solution

if (  ( (FalSafeValue < 359) ||  !digitalRead(tempFalSafe))     &&     (failFlag == false)  ) {   // do the OR part first

differs from

if (  (FalSafeValue < 359)     ||       (!digitalRead(tempFalSafe)  && (failFlag == false)  )     ) {   // do the and part first

Your code will probably be easier to follow if you read the value into a variable and then use the variable in the if statement

byte tempVal =  ! digitalRead(tempFalSafe);
if ((FalSafeValue < 359) ll tempVal && (failFlag == false)) {

Those complex IF statements can be notoriously difficult to create. With 3 variables there are 8 possibilities - have you got the correct one? Should only one of the 8 be included - i.e. should the other 7 be definitely excluded?

If it was my code I would break them out at least into nested single statements. But I would prefer to use one (or two) of the tests to eliminate stuff completely to reduce the need for nesting.

...R