newbie question: which code to use for serial comms on Mega's tx1 (pin18)?

Hi, am I right or wrong in thinking I need to use the SoftwareSerial library to use digital pin 18 ("tx1") for RS232 output on the Mega2560?

I have the appropriate TTL->RS232 interface hardware already in place.

I'm already using Serial.print() to send debugging messages to the host PC, so I'll need to be able to specify pin18 for other things.

I was further confused by the name 'software serial' as I thought that TX1 etc. might be a true USART, so I'm trying to find that out in the meantime.

Thanks Matt

The reference of the Serial libray explains it all : http://www.arduino.cc/en/Reference/Serial

Use : Serial1.begin(); and : Serial1.println("Hello");

The Arduion Mega has 4 real hardware serial ports. The first one "Serial" is used to communicate with the computer, the other three "Serial1", "Serial2" and "Serial3" can be used for your project.

The SoftwareSerial is for example when an Arduino Uno desperately needs an extra serial port. But it has a big influence on the rest of the code.

Many thanks for explaining! The reference page on the Serial library [u]does[/u] mention Serial1...Serial3 as isolated concepts, but it did not show how to implement them. When I've finished this project, I'll be happy to offer some code examples to add to the page so nobody has to look much further.

You may find something useful in serial input basics.

...R

Thanks, but the 'serial input basics' post does not mention how to address Serial1,2,3 etc. It's a very useful tutorial though and thanks for putting so much effort into it.

I would simply like to see/provide examples on the same page about how to use any serial port, including the hardware serial monitor, the dedicated Serial1..3..n ports, and establishing tx/rx on any other pins. I think this would make it easier for people who know what they want to do, but aren't sure what methods to use. :)

protomoose: Thanks, but the 'serial input basics' post does not mention how to address Serial1,2,3 etc. It's a very useful tutorial though and thanks for putting so much effort into it.

Just change Serial to Serial1 etc

...R

Yes, I get that now. I just couldn't see it at first glance. Thanks!