How do you do comparison with a case within a switch?
switch (i){
case (i<3):
//Do something while i is less than 3
}
This doesn't Compile and I'm new... Unfortunately for me the Arduino Ref doesn't have an example. Which means you cannot do it or I'm doing it wrong. Any pointers appreciated.
if things are complex you could create a function that returns an unique number for the different conditions.
simple example
int i = sign(strcmp(s1, s2));
switch(i)
{
case -1: // s1 < s2 alphabetically
break;
case 0: // s1==s2
break;
case 1: // s1 > s2 alphabetically
}
Note that enums are allowed in a switch statement
enum Days {Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday};
Days d = f(...);
switch(s)
{
case Saturday:
case Sunday:
serial.println("Weekend");
break;
case Monday:
case Tuesday:
case Wednesday:
case Thursday:
case Friday:
serial.println("Work days");
break;
}