serial.available() not returning anything

hi . i am new to this all i have one question to begin with. I was trying to make this script work but i have one problem

// led wired + to pin 12, resistor to positive +5v

int outPin = 12; // Output connected to digital pin 12
int mail = LOW; // Is there new mail?
int val; // Value read from the serial port
void setup()
{
pinMode(outPin, OUTPUT); // sets the digital pin as output
Serial.begin(9600);
Serial.flush();
mail = HIGH; // start off with lights out
}

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

if (val == 110) // n = 110 in dec
{
mail = LOW; // HIGH is off because led is connected to +5v on the other side
}

else if (val == 109) //109 = m in dec
{
mail = HIGH; // LOW is on because led is connected to +5v on the other side
}
}

// Set the status of the output pin
digitalWrite(outPin, mail);
}

but the serial.available() does not work not return anything.

Are you saying it doesn't return anything (it doesn't return?) or it always returns zero?

How are you sending things?
If you're using the serial monitor, last time I looked, it didn't send anything until you hit "send" - it doesn't send single characters like, say, Hyperterm.

if (val == 'n') :wink:

thanks for replying and it helped also .

but i found out that the real problem lies in the python file that it is reciving information from when this is uploaded to the chip ..... that is for another forum . Thanks for the help