Sending serial data over the USB to Arduino

I'm trying to use the serial monitor (and ultimately my c# program) to send serial data to the Arduino over the USB port. The program turns on and off an LED. So far I've had no luck with the serial monitor, its still blank.

This is my code :

void setup() {

}

void loop() {

String Q;
String readString = "";
while(Serial.available()){
delay(1);
if(Serial.available()>0){
char c = Serial.read();

if (isControl(c)){
break;
}
readString+= c;
}
}

Q = readString;

if(Q=="on"){
digitalWrite(13,HIGH);
}
if(Q=="off"){
digitalWrite(13,LOW);
}

}

void setup() {
 
}

Oops

Please remember to use code tags when posting code

TheMemberFormerlyKnownAsAWOL:

void setup() {

}



Oops

Please remember to use code tags when posting code

Ah I forgot to set the baud rate
void setup() {
Serial.begin(9600);
}
Thank you

The serial input basics tutorial may be of interest. It uses non-blocking methods to read serial data into a null terminated character array (string) thus avoiding the potential memory problems that can be caused by the String class in small memory systems. See the evils of strings.