Is it possible to run a function in a loop with a button?

I would like to teach a nephew about AND, OR … gates.
I have functions like this

void and() {
if (buttonState1 == HIGH && buttonState2 == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
void or() {
if (buttonState1 == HIGH || buttonState2 == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}

Basically “void and()” function lights up a led when two buttons are pressed, and “void or()” function light up a led when one or two buttons are pressed.

I would like to press a button with a name “and” in blynk app, arduino would run “void and()” function in loop;
and when I press a button with a name “or” in blynk app, arduino would run “void or()” function in loop; …

Is this possible?

this is how to do if then else


BLYNK_WRITE(V0) // mode selection drop down menu
{
  setMode = param.asInt();
  {
    if (setMode == 1) // reset max temps
    {
      foodTemperatureMax = 0;
      heatTemperatureMax = 0;
      Blynk.virtualWrite(V7, 0);
      Blynk.virtualWrite(V8, 0);
    }
    else if (setMode == 2) // heat pre-warning offset up
    {
      heatWarningOffset = heatWarningOffset + 1;
      Blynk.virtualWrite(V13, heatWarningOffset, "'C");
    }
    else if (setMode == 3) // heat pre-warning offset dwn
    {
      heatWarningOffset = heatWarningOffset - 1;
      Blynk.virtualWrite(V13, heatWarningOffset, "'C");
    }
    else if (setMode == 4) // food pre-warning offset up
    {
      foodWarningOffset = foodWarningOffset + 1;
      Blynk.virtualWrite(V14, foodWarningOffset, "'C");
    }
    else if (setMode == 5) // food pre-warning offset dwn
    {
      foodWarningOffset = foodWarningOffset - 1;
      Blynk.virtualWrite(V14, foodWarningOffset, "'C");
    }
    else if (setMode == 6) // spare
    {
      ///TBA
    }
  }
}

https://www.arduino.cc/reference/en/language/structure/control-structure/if/

Thank you.