How to turn on/off LED using String?

Hey guys, so I was assigned by my teacher to turn on/off a LED using String() command just wanted to know if there are any sources or reference available. Example: COM4 (On Off On Off) LEDs.

What have you done so far?

I doubt he actually said that, so you are interpreting a bit, right? String functions deal with, well, strings. That is nothing to do with LEDs.

Would you by any chance have to send a command from one Arduino to another?

Simple code that you might be looking for.

// zoomkat 8-6-10 serial I/O string test
// type a string in serial monitor. then send or enter
// for IDE 0019 and later

int ledPin = 13;
String readString;

void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT); 
  Serial.println("serial on/off test 0021"); // so I can keep track
}

void loop() {

  while (Serial.available()) {
    delay(3);  
    char c = Serial.read();
    readString += c; 
  }

  if (readString.length() >0) {
    Serial.println(readString);

    if (readString == "on")     
    {
      digitalWrite(ledPin, HIGH);
    }
    if (readString == "off")
    {
      digitalWrite(ledPin, LOW);
    }

    readString="";
  } 
}

sorry for the late reply.

const int ledPin = 13;
String incomingByte;  
void setup() {
  Serial.begin(9600);
  pinMode(ledPin, OUTPUT);

}

void loop() {
  if (Serial.available() > 0) {

    incomingByte = Serial.read();

    if (incomingByte == 'On') {
      digitalWrite(ledPin, HIGH);
    }
    if (incomingByte == 'OF') {
      digitalWrite(ledPin, LOW);
    }

  }
}
    incomingByte = Serial.read();

    if (incomingByte == 'On') {

A single byte is never going to be equal to 'On' or 'OF'.