My thoughts... your variables should have better names to match their function and types.
myString implies a null terminated C string with no clue regarding it's function.
'S' is a single command character and is best stored in a char variable rather than a multi-character string.
I recommend this site for C++ tutorials, and this section in particular regarding Hungarian Notation
http://www.learncpp.com/cpp-tutorial/29-hungarian-notation/
constant char chTerminator = ",";
char chCommand = '?'; // A command character variable
int nBrightness = 0; // An integer variable (do you plan to use negative numbers?)
String strBrightness = "0"; // Always assign variables and objects with 'safe' values.
Is the servo code you posted a reference, or your actual project? It is not a good example.
Start your project by coding the keyboard input, and print the result. Once satisfied, then add other code to handle it.
I suggest examining each input character:
if it is a digit append it to strBrightness...
If a valid command char, assign it to chCommand
If chTerminator, convert strBrightness to int and assign it to nBrightness then execute your command if brightness is reasonable ( 0 to 255 )?
Default ignore
char chLastCharacterRead = Serial.read(); // one char
if (isDigit(chLastCharacterRead))
{
strBrightness += chLastCharacterRead; // Builds an unsigned numeric string
}
else // command or terminator or garbage
{
// Setup a case structure here to test for a command char in the range expected or chTerminator, default to ignore garbage
}