email checker help

ok I am modifying a email notifier I found on-line, it is supposed to flash when I get a new email (I have a python script that sends "m" to the serial port when I have mail and "n" when I don't) but when I get a email it flashes... and dosnt stop I have gotten this to work without flashing (just running the code from the Internet) but I would like it to flash.

code:

// led wired + to pin 12, resistor to positive +5v
int value = 255;
int ledpin = 11; // Output connected to digital pin 12
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port
void setup()
{
 Serial.begin(9600);
 Serial.flush();
}

void loop()
{
 // Read from serial port
 if (Serial.available())
 {
   val = Serial.read();
   Serial.println(val, BYTE);

if (val == 110)
  for(value = 255; value >= 0; value-=5) 
      { 
          analogWrite(ledpin, value);           
          delay(30);                            
      } 


    while (val == 109)
    {
    for(value = 255; value >= 0; value-=5) 
      { 
          analogWrite(ledpin, value);           
          delay(30);                            
      }  
    for(value = 0; value <=255; value+=5)   
      { 
          analogWrite(ledpin, value); 
          delay(30); 
      }
      Serial.read();
    }

 }
}

You were not setting your second Serial.read() to any variable. Also, if you keep your formatting the same it makes it much easier to read. I made a couple other changes you can check out.

// led wired + to pin 12, resistor to positive +5v
int value = 0;
int ledpin = 11; // Output connected to digital pin 12
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port
void setup()
{
  Serial.begin(9600);
  Serial.flush();
}

void loop()
{
  // Read from serial port
  if (Serial.available())
  {
    val = Serial.read();
    Serial.println(val, BYTE);
  }

  if (val == 110)
  {
    if (value > 0) //we only want to fade it down if it was on
    {
      for(value = 255; value >= 0; value-=5)
      {
        analogWrite(ledpin, value);          
        delay(30);                            
      }
    }
  }

  if (val == 109)
  {
    for(value = 255; value >= 0; value-=5)
    {
      analogWrite(ledpin, value);          
      delay(30);                            
    }  
    for(value = 0; value <=255; value+=5)  
    {
      analogWrite(ledpin, value);
      delay(30);
    }
  }
}

ok thank you for that I always clean up my code after Im done writing it and I guess I just forgot.