Try something like this:
// code for receiving a value followed by a letter
// that writes the value to an analog pin corrosponding to that letter
int analogPins[] = {3, 5, 6, 9, 10, 11}; // 'a','b','c','d','e','f'
void setup()
{
Serial.begin(9600);
}
void loop()
{
serviceSerial();
}
// serviceSerial expects data in the form:
// "255a" - analog writes 255 to pin 3
// "127c" - analog writes 127 to pin 6
// "0f" - analog writes 0 to pin 11
void serviceSerial()
{
static int val = 0;
if ( Serial.available()) {
char ch = Serial.read();
if(ch >= '0' && ch <= '9') // is ch a number?
val = val * 10 + ch - '0'; // yes, accumulate the value
else if(ch >= 'a' && ch <= 'f'){ // is ch a letter for one of the analog pins?
int pin = analogPins[ch - 'a']; // use the letter to index into the pin array
analogWrite(pin, val); // write the previously received val to the pin
}
}
}
sending a value followed by a letter writes the value to an analog pin corrosponding to the letter :
send: "255a" to analog writes 255 to pin 3
send "127c" to analog writes 127 to pin 6
send: "0f" to analog write 0 to pin 11
I have not run the code but it should get you going in the right direction.
Have fun!