Combine 2 "if" statements SOLVED!

I'm looking to run the buzzer when either IF statement is true. How would I code it?

void LongBuzz() // This function is outside the loop
{
  digitalWrite(5, HIGH);
  delay(2000);
  digitalWrite(5, LOW);
}

void loop() {

if (accelerationX > 100 && accelerationX < 500)
  {
    LongBuzz();  // Run buzzer function
  }

  if (accelerationY > 100 && accelerationY < 500)
  {
    LongBuzz();  // Run buzzer function
  }
  }

You need a logical or statement

if ((accelerationX > 100 && accelerationX < 500) || (accelerationY > 100 && accelerationY < 500))
{
  LongBuzz();  // Run buzzer function
}

You ca use like this way too:

if ((accelerationX > 100 and accelerationX < 500) or (accelerationY > 100 and accelerationY < 500))

C++ Keyword Synonyms
and             &&
and_eq          &=
bitand          &
bitor           |
not             !
not_eq          !=
or              ||
or_eq           |=
xor             ^
xor_eq          ^=

Ref: IF  with AND and OR fuctions - #2 by robtillaart

RV mineirin

The logical OR (||) worked! Slowly, I'm learning & understanding more Arduino code. Thanks everyone! :sunglasses: