Arduino Mega Multiple Serials to same computer help

The documentation states that Arduino Mega jas 3 serial ports. But I will like to know what device I need to create the second USB connection and how I code to separate RX and TX information to the different port.

jecalderon:
what device I need to create the second USB connection

You need a USB to TTL serial adapter. Traditionally this was done with the FTDI FT232 chip but in recent years the WCH CH340 chip has become very popular for its lower price. There are several other less popular options that will work fine.

You can get them in a cable form:

Or as a breakout board:

I prefer the breakout board and they seem to be cheaper too. You need one adapter for each serial port and each will create a separate virtual COM port on the computer.

jecalderon:
how I code to separate RX and TX information to the different port.

Each hardware serial port has its own object: Serial, Serial1, Serial2, Serial3. So if you want to configure Serial2 to communicate at 9600 baud, you do this:

Serial2.begin(9600);

If you want to print to Serial1 you do this:

Serial1.print("foo");

More information:

I have it right now on the desk.