byte msg; 
int led = 2;

void setup()
{
  pinMode(led, OUTPUT); 
  Serial.begin(9600);    
}
void loop()
{
  if (Serial.available()>=1) 
  // character received
  {
    msg = (char)Serial.read();
    if (msg == 'n')  
    {
      // command n: LED on
      digitalWrite(led,HIGH);
      // confirm
      Serial.print("n"); 
    }
    if (msg == 'f')  
    {
      // command f: LED off
      digitalWrite(led,LOW);
      // confirm
      Serial.print("f"); 
    }
  }
}


