Go Down

Topic: Mega 2560: how does it works Serial1 ? (Read 5532 times) previous topic - next topic

valerio_sperati

Hi everyone,
I'm trying to display simple messages on serial monitor, through Serial and Serial1,
but I'm having some problem.
The board is Arduino MEGA 2560, the Ide is Arduino 0022, the system is Ubuntu 10.04,
the board is automatically connected through serial port /dev/ttyACM0

Both Serials have been initialised in the setup():

Code: [Select]

Serial.begin(9600); 
Serial1.begin(4800);


and my loop() simply calls

Code: [Select]

Serial.print("GOOD\t\t");
Serial1.print("WRONG");
Serial.println();
Serial1.println();
delay(100);


Now here is the problem: if I open the serial monitor and set baudrate to 9600,
the message "GOOD" is correctly displayed,
but if I change the baudrate to 4800
the message "WRONG" is not displayed!
I just see meaningless symbols, like xxxøxøxøxø
Maybe I missed something about the use of Serial?



 

Grag38

you can not 'see' the wrong message by serial monitor.

in your code you are transmitting 2 words thru 2 differents serial out.

But the monitor window can only display datas from the Serial, not from Serial1, Serial2, Serial3...

If you want to see the "WRONG" word you must create a loop between TX0/RX0 and TX1/RX1, so from when you print your word, it will be send to the rx of the other port and Serial will print it.

ok.

So : connect a wire from TX0 to RX1 and another to RX0 to TX1.

Set the baudrate at the same value on each Serial begin statement. And it will works

Go Up