Wanted to see if anyone knows anything about using USB and XBee simultaneously. I know that you cannot use them at the same time as there is only one Serial port, but i was wondering about using a transistor as a switch so that I can turn a digital pin HIGH which would connect the XBee and Recieve Pin, and turn the pin LOW which would disconnect the XBee from the Receiver pin allowing communication between the computer and Arduino.

Is this possible? Has anyone tried it? If this is not the best solution, what is?

If your get your e-mail, do you have any trouble identifying who the message is from? No, of course not, because the message is tagged with who it's from. There's a real good reason for that, and a hint about what you have to do.

The PC that is sending messages needs to tag its messages, as does whatever the other XBee is attached to.

Unlike when a PC connects to a serial port, the Arduino end of the serial port IS the TX/RX pins. Any number of things can read the state of the RX pin and set the state of the TX pin.

When the Arduino reads data from the RX pin, it puts in an a buffer, for the Serial.available() and Serial.read() functions to operate on.

When the Arduino sends data to the serial port, using Serial.write() or Serial.print(ln)(), the TX pin is toggled HIGH and LOW at specific times. This toggling is read by the device on the other end of the serial port.

The XBee also monitors the TX pin. When it sees the TX pin toggle, it broadcasts that data over the air.

When the XBee receives data over the air, it toggles the RX pin in the same manner that the PC does.

So, the Arduino can get data, on the RX pin, from the PC and the XBee at the same time, and can send data to the PC and XBee at the same time.

The thing that you can't do is send data to the XBee OR the PC. You send data to the XBee AND the PC.

Just like talking in a room full of people, you have to identify who the message is for, and ensure that all listeners respond only to messages send specifically to them.

I can turn a digital pin HIGH which would connect the XBee and Recieve Pin, and turn the pin LOW which would disconnect the XBee from the Receiver pin allowing communication between the computer and Arduino.

You could use an analogue MUX for this, but it would a lot easier just to use software serial for the XBee.

I have a device that needs to connect to the Arduino via its USB Port to a computer. The computer sends a command via a terminal to the Arduino. Once the data has been received by the Arduino, the Arduino needs to be able to use the XBee's to send and receive commands only. It will not use USB again until it has been reset.

Currently, if I plug in the XBee to the Arduino's TX/RX pins, I cannot send any messages to the Arduino via HyperTerm or the Arduino IDE's Serial Monitor.