Can I use a case/switch statement with two variables

iam a new comer in arduino. curently learning through the examples. now iam learning the 'the case switch 2 statement. i need to send a char ' on' from serial port and to on an led. how can be this done.the practical problem is that i couldnt type more than a letter in the case statement. eg- case'on':

pls help

Compare the input to the required string using memcmp() and use if/else to do the comparison based on the result.

i need to send a char ' on'

Post a picture of your keyboard with the on key circled, please.

If you can't, because your keyboard doesn't have an on key, then you need to reconsider what you are trying to do. In my case, my keyboard doesn't have an on key, so I would have to send two characters, 'o' and 'n', followed by some kind of delimiter (such as a carriage return), and have the Arduino read and store input until the delimiter arrived.

You have a choice to make. You must either make all your commands a single character or you must not use switch / case and use If / else if statements instead.

You could also build a table of acceptable commands, along with a corresponding constant, then have a function that returns the constant for any command parsed. Then, you can use the constant in a switch statement.

const byte COMMAND_UNKNOWN = 0;
const byte COMMAND_ON = 1;
const byte COMMAND_OFF = 2;
const byte COMMAND_STOP = 3;

int getCommandValue(char *command)
    typedef struct 
        char* command;
        int value;
    } _command;
    static _command commands[3] = 
        {"on", COMMAND_ON},
        {"off", COMMAND_OFF},
        {"start", COMMAND_START}
    for (int i=0; i < sizeof(commands)/sizeof(command); i++)
        if (strcmp(commands[i].command, command) == 0)
            return commands[i].value;

void loop()
    char command[] = "on";

    switch (getCommandValue(command))
        case COMMAND_ON:

Also see this thread: