Control LED with fading effect.

Hi Everyone,
What I'm trying to accomplish is to turn on my LEDs with fading in effect by serial data from my Keyboard. I got it to work the way I want it to but how do I stop it from repeating the fading in effect from the beginning when the LEDs are at its maximum brightness?

Example: When I pressed the "H" key on my keyboard the LEDs starting to fade from 0 to maximum brightness, but when I pressed "H" again its repeat the same action, I don't want that. Is there a way to keep its at the full brightness even if I press the "H" key on my keyboard again. Thanks Everyone.

int LED = 9; // the pin that the LED is attached to
int incomingByte;      // a variable to read incoming serial data into

void setup() 
{ 
  Serial.begin(9600); // initialize serial communication:
  pinMode(LED, OUTPUT); // initialize the LED pin as an output:
}

void loop() 
{
  if (Serial.available() > 0) // see if there's incoming serial data:
    {
      incomingByte = Serial.read(); // read the oldest byte in the serial buffer:
      if (incomingByte == 'H') // if it's a capital H (ASCII 72), turn on the LED:
        {
          for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) // fade in from min to max in increments of 1 points:
           {
             analogWrite(LED, fadeValue); // sets the value (range from 0 to 255):
             delay(30); // wait for 30 milliseconds to see the dimming effect
           }
        }

      if (incomingByte == 'L') // if it's an L (ASCII 76) turn off the LED:
        {
           for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) // fade out from max to min in increments of 1 points:
            {
              analogWrite(LED, fadeValue); // sets the value (range from 0 to 255):  
              delay(30); // wait for 30 milliseconds to see the dimming effect                         
            }
        }
    }
}

Take a look at this thread: Basic code issues for using an IR sensor to dim an LED between states - #5 by wildbill - Programming Questions - Arduino Forum - there's a similar problem posed, with a solution you should be able to adapt.

You could use a boolean to make sure that the LED is not already at full brightness.

int LED = 9; 
boolean LEDfull = false;
boolean LEDempty = true; // just in case this happens with the 'L' too
int incomingByte;     

void setup() 
{ 
  Serial.begin(9600); 
  pinMode(LED, OUTPUT); 
}

void loop() 
{
  if (Serial.available() > 0) 
    {
      incomingByte = Serial.read(); 
      if (incomingByte == 'H' && LEDfull == false) 
        {
          for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) 
           {
             analogWrite(LED, fadeValue); 
             delay(30); 
           }
           LEDfull = true;
           LEDempty = false;
        }

      if (incomingByte == 'L' && LEDfull == true) 
        {
            if (LEDempty == true) {
               return;
            }
            else {
           for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1) 
            {
              analogWrite(LED, fadeValue);  
              delay(30);                         
            }
        }
    }

    }
}

Hey Arduinoisme, Thanks for your help. I don't know how but I manage to mess around with your code and it work the way I wanted it to now, I'm completely new to Arduino coding. Hey wildbill, I tried to incorporate your code to mine but I have to keep pressing the "H" key to increase the brightness. I really like your code, I never knew you could change the fading like that. It's very cool. I'll keep trying to get your code to work with mine. Here's the updated code I combined with Arduinoisme, hope someone could make a use of it.

int LED = 9; 
boolean LEDfull = false;
boolean LEDempty = true; // just in case this happens with the 'L' too
int incomingByte;     

void setup() 
{ 
  Serial.begin(9600); 
  pinMode(LED, OUTPUT); 
}

void loop() 
{
  if (Serial.available() > 0) 
    {
      incomingByte = Serial.read(); 
      if (incomingByte == 'H' && LEDfull == false) 
        {
          for(int fadeValue = 0 ; fadeValue <= 255; fadeValue +=1) 
           {
             analogWrite(LED, fadeValue); 
             delay(30); 
           }
           LEDfull = true;
           LEDempty = true;
        }

      if (incomingByte == 'L' && LEDfull == true)
        {
           for(int fadeValue = 255 ; fadeValue >= 0; fadeValue -=1)
            {
              analogWrite(LED, fadeValue);
              delay(30);
            }
            LEDfull = false;
            LEDempty = false;
        }
    }
}