Question on Switch case statement

Is it possible to use Boolean operators with case? something like below…

case 1 || 2:
do this;
break;

and

case > 5 && < 10:
do this;
break;

No.
you cam do lists of valueseg

case 1:
case 2:
case 3:

Mark

holmes4:
No.
you cam do lists of valueseg

case 1:

case 2:
case 3:



Mark

That's an OR, though: not sure if it's possible to do an AND?

JimboZA:

holmes4:
No.
you cam do lists of valueseg

case 1:

case 2:
case 3:



Mark

That's an OR, though: not sure if it's possible to do an AND?

It's not possible to be more than one case at a time, so OR is all you need. His AND example was just a range greater than 5 and less then 10, so the values 6-9 satisfy it.

There's also the case range that gcc supports:

   case 2 ... 5:

simple example of the options of switch

int x;

void setup()
{
  Serial.begin(115200);  // use fastest serial possible
  x = 0;

}

void loop()
{
  x++;

  switch(x)
  {
  case 0: 
    Serial.println("zero"); 
    break;
  case 1 ... 9: 
    Serial.println("between 1 and 9"); 
    break;
  case 10:
  case 11:
  case 13:
    Serial.println(x);
    break;
  case 15:
    x = 0;
    break;
  default:
    Serial.println(".");
  }
  delay(1000);
}

Thank you all for your responses!