Serial input in switch statement that can read multiple characters as a case.

I'm using an Arduino that is communicating with my PC via VB EXPRESS using the serial input. Im using the VB to control 8 different channels with a switch statement. Each channel has four different button settings in VB. I had no problem setting up the original on off statements between the two but im trying to play around with the Duty Cycle and PWM by causing an LED to fade in and out for now. I used an individual character for the first set of on off commands but which was fine because i only needed 16 characters. Now that i need 32 characters I've run into a problem though, because there are only 26 alphabet characters. I would like to send a string of characters for example send 'aa' as one of the cases but i cant seem to get the string to work. If anyone has any advice on how i may be able to do this in a switch statement that i can fade an LED in and out on or mess with the Duty Cycle/ PWM i would greatly appreciate it. Thanks in advance

Look at the Thread serial input basics which has examples for single and multiple characters.

If you use upper and lower case letters and digits you have 62 choices with a single character - more if you include the other human-readable characters.

...R

I would like to send a string of characters for example send 'aa' as one of the cases but i cant seem to get the string to work. If anyone has any advice on how i may be able to do this in a switch statement that i can fade an LED in and out on or mess with the Duty Cycle/ PWM i would greatly appreciate it.

I don't know much about cases and switches, but you can capture a command string of characters that is sent and use the String functions to evaluate the contents fairly easily. Below is code I use for servos where position command values are are sent to specific servos.

//zoomkat 11-22-12 simple delimited ',' string parse 
//from serial port input (via serial monitor)
//and print result out serial port
//multi servos added 
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservoa, myservob, myservoc, myservod;  // create servo object to control a servo 

void setup() {
  Serial.begin(9600);

  //myservoa.writeMicroseconds(1500); //set initial servo position if desired

  myservoa.attach(6);  //the pin for the servoa control
  myservob.attach(7);  //the pin for the servob control
  myservoc.attach(8);  //the pin for the servoc control
  myservod.attach(9);  //the pin for the servod control 
  Serial.println("multi-servo-delimit-test-dual-input-11-22-12"); // so I can keep track of what is loaded
}

void loop() {

  //expect single strings like 700a, or 1500c, or 2000d,
  //or like 30c, or 90a, or 180d,
  //or combined like 30c,180b,70a,120d,

  if (Serial.available())  {
    char c = Serial.read();  //gets one byte from serial buffer
    if (c == ',') {
      if (readString.length() >1) {
        Serial.println(readString); //prints string to serial port out

        int n = readString.toInt();  //convert readString into a number

        // auto select appropriate value, copied from someone elses code.
        if(n >= 500)
        {
          Serial.print("writing Microseconds: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.writeMicroseconds(n);
          if(readString.indexOf('b') >0) myservob.writeMicroseconds(n);
          if(readString.indexOf('c') >0) myservoc.writeMicroseconds(n);
          if(readString.indexOf('d') >0) myservod.writeMicroseconds(n);
        }
        else
        {   
          Serial.print("writing Angle: ");
          Serial.println(n);
          if(readString.indexOf('a') >0) myservoa.write(n);
          if(readString.indexOf('b') >0) myservob.write(n);
          if(readString.indexOf('c') >0) myservoc.write(n);
          if(readString.indexOf('d') >0) myservod.write(n);
        }
         readString=""; //clears variable for new input
      }
    }  
    else {     
      readString += c; //makes the string readString
    }
  }
}

Thanks for the help that's just what i was looking for