I'd suggest storing the input in a char array, because the String class has some issues outstanding at the moment.
You would need to initialise the serial port in setup() as normal, and in loop() you would need a code fragment to read from the serial port and process the data read. For example (incomplete and untested):
const int MAXLEN = 32;
int length = 0;
char buffer[MAXLEN+1];
void loop()
{
if(Serial.available())
{
char ch = Serial.read();
if((ch == '\r') || (ch == '\n'))
{
if(length > 0)
{
processMessage(buffer);
}
length = 0;
}
else if(length < MAXLEN)
{
buffer[length++] = ch;
buffer[length] = 0;
}
else
{
// buffer full - discard received character
}
}
}
void processMessage(char *msg)
{
// your code here
}