It has been suggested that you put each { and } on a separate line, and indent the code properly, so you can see what is going on.
while (Serial.available()) {
if (Serial.available() >0) {
char c = Serial.read();
readString += c;}
}
should be:
while (Serial.available())
{
if (Serial.available() >0)
{
char c = Serial.read();
readString += c;
}
}
Some things you need to ask yourself. Serial.available() returns a number - the number of bytes available to read. You have an implicit test in the while statement, and an explicit test in the if statement. Why?
Make it an explicit test in the while statement, too.
Next, the body of the while statement will not be executed unless there is serial data available to read. In the body, the first thing you do is test whether there is serial data available to read. The only thing that can change whether there is data available to read is a call to Serial.read(), which is not happening between the while test and the if test. What useful purpose does the if test serve?
Serial data is sent slowly. As written, whatever is available to be read when the while test is first evaluated is all that will be read, since reading serial data is orders of magnitude faster than receiving serial data. If, in the Serial Monitor, you type "12345678" and hit send, the data will arrive at the serial port one character at a time, and will be processed during hundreds, thousands, or even millions of passes through loop. On any given pass, there being nothing that takes very long to do, you will read and deal with one character at a time. Is that really what you want to do? Or, are you trying to receive a number of characters that make up a packet, and process them all as a packet?
If it is the latter, you have two choices. You can use zoomkat's method of adding a delay in the while loop, so you waste a bunch of time waiting around, hoping that all the data that makes up a packet arrives before you assume that you have received a complete packet.
Or, you can send an explicit end-of-packet marker. With a marker (; as in "12345678;" for example), you read whatever data is available, append it to readString, and end the while loop with no delay. If the character that was read was the end of packet marker, you set a flag and break out of the while loop.
You do nothing with the data in readString unless that flag is set.
Some minimal time with the search field, and "end of packet marker" or zoomkat's name will get you code to implement either method.
Once you have a packet, in readString, you need to extract the character array from the string (using toCharArray), convert that array to an integer (using atoi), and perform your switching based on that integer, not some character values.
case '32':
'32' is a multibyte character. While this is legal syntax in C, there is no support for multibyte characters on the Arduino. If you want to compare the value in a character array to a constant collection of characters, double quotes are required. The switch/case construct can not be used to do this. The strcmp() function in a series of if tests could.