Why SerialEvent doesn't work on Uno as on mega ?

Hello,

I have a sketch which use the serialEvent :


int LedPin = 13;

void setup()
{
Serial.begin(115200);
pinMode(LedPin, OUTPUT);
}

void loop()
{
}

void serialEvent()
{
char ch = Serial.read();
if (ch==53)
{
digitalWrite(LedPin, HIGH);
delay(250);
digitalWrite(LedPin, LOW);
delay(250);
}
}

If I use the SerialMonitor to send the char to the arduino : All is good
If I send the char with the TX/RX pin nothing done (with the USB plug off, of course)

In first, I thought that my message send through the RX/TX pin wasn't good.
So, I have test the same sketch with an arduino Mega and send the same char trough the serial port 1 :


int LedPin = 13;

void setup()
{
Serial1.begin(115200);
pinMode(LedPin, OUTPUT);
}

void loop()
{
}

void serialEvent1()
{
char ch = Serial1.read();
if (ch==53)
{
digitalWrite(LedPin, HIGH);
delay(250);
digitalWrite(LedPin, LOW);
delay(250);
}
}

In this case all is good .... why it doesn't work with the Uno ?

Please help me, I don't understand....

Many thanks

marouille:
If I send the char with the TX/RX pin nothing done (with the USB plug off, of course)

It should work. How do you "send the char" to the Tx/Rx pin, exactly?