Reading a string from the serial port

There are a gazillion examples around (albeit mostly on the old forum I admit).

Try something like this

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

void loop() {
  char myString[100];
  char *ms_ptr = myString;

  // oops, this was wrong if (Serial.read() > 0) {
  if (Serial.available() > 0) {
     *ms_ptr = Serial.read();
     ms_ptr++;
     *ms_ptr = '\0';
  }
}

This will never stop reading chars though. Normally you also have a test for a end of string character at which point you break out of the loop and do some work with the string.

EDIT: oops, Serial.read -> Serial.available


Rob