Using Two Serial Ports Arduino UNO

Hi. I am using an Arduino UNO hooked up to my OBD through the digital pins 0 (RX) and 1 (TX) as well as with the computer via USB.

Can I have both serial ports running at the same time? Such as reading/sending info to and from both the RX/TX pins and via USB at the same time? Or do I have to switch inbetween them using the soft serial port library? If using the library do how access the USB since the example shows the serial communication is all pins.

http://arduino.cc/en/Tutorial/TwoPortReceive

Thank you very much for reading.

edit* Typo pointed out to me by Caltoa "I am using an Arduino UNO hooked up to my computer through the digital pins 0 (RX) and 1 (TX) as well as with the computer via USB."

The hardware serial port inside the microcontroller on the Arduino board uses pin 0 (RX) and pin 1 (TX). When you connect the Arduino Uno to a computer, the usb-to-serial part on the Uno board connects to pin 0 and pin 1. It is possible to connect something else to pin 0 and 1, by overriding the signals of the usb-to-serial.

How did you connect pin 0 and 1 to the computer ? with a RS232-to-ttl-serial converter module ? I hope you did, there is no other way. However, there is no advantage to use pin 0 and 1, since they are already used for the (virtual) serial port on the computer via the usb plug.

When you want two serial ports, you need to use SoftwareSerial to create a second serial port. You could use SoftwareSerial for example with pin 2 and 3.

There are other boards that have more possibilities. The Arduino Leonardo has a spare hardware serial port, and the Arduino Mega 2560 has 3 spare hardware serial ports. With 'spare' I mean an extra serial port beside the normal serial communication via the usb bus.

Why do you want to have two serial ports connected to the same computer ? Is it for developing a special communication protocol for some device ?

Ah shoot, sorry.

I meant to say that I was connecting the UNO to and OBDII for a car via 0 and 1 and also the computer via usb at the same time. So in order to use two serial ports, I would have to use the pins and use SoftwareSerial? I was hoping I use treat the virtual serial port (USB) like a soft port.

No, the usb-serial is hardwired to pin 0 and 1. For the Arduino Uno, you need the SoftwareSerial with two other pins.

The Arduino Leonardo would be a good option. You can use the hardware serial port on pin 0 and 1, since the communication via the usb is done with a software serial implementation. But that software serial needs extra memory, so you have less available for a sketch.

You can somewhat have the USB and OBDII (assuming it is TTL) connected to the same tx/rx arduino pins. You need a small signal diode in the line between the arduino rx and OBDII tx with the diode's band on the OBDII tx side.