Multiple "OR" structure for Arduino.

Hi,
I’ m trying to use the following 'OR structure

==================================
if
(
digitalread(pin#)== HIGH
OR digitalread(pin#)== HIGH
OR digitalread(pin#) == HIGH
OR digitalread(pin#) == HIGH
Etc… etc
)

{ do this … } else { do that …}

… replacing the ‘OR’ with ’ || ’ operand

It compiles OK , but doesn’t give the desired result
i.e. If anyone one ( or more) conditions are met “… this” is executed
Otherwise " …that " is executed.

Thanks
MikeH

If anyone one ( or more) conditions are met “… this” is executed

Well given you

replacing the ‘OR’ with ’ || ’ operand

Then that is what it will do.

So check those pin reads with serial print commands.

As an aside, LOW is 0 and HIGH is 1 (they're just #defines), so a HIGH is true, and a LOW is false.

So

if (digitalRead(2) || digitalRead(3)) { ... }

works too.

Do you mean

 if (digitalRead(pin#)) doThis;
 else if (digitalRead(pin#)) doThat;
 else if ...

What result do you get?

Mikeatwh: Hi, I' m trying to use the following 'OR structure

if 
(
      digitalread(pin#)== HIGH
      OR digitalread(pin#)== HIGH
      OR  digitalread(pin#) == HIGH
      OR  digitalread(pin#) == HIGH
      Etc.... etc
)

You can use either "or" (lower case) or "||! to do that.

But I would be wary of making a compound test and then expecting an ELSE to work as you expect. It is very easy to get the logic wrong. You have 4 tests which means 16 possibilities and any of the other 15 will make it fail.

I would build that as a cascade to make it easier to understand

if (xxxx) {
  if (yyyy)  {
     if (zzzz) {
        if (aaaa) )

because then it is easy to put the ELSE in the right place

...R