How to read data from any of the usb ports using the arduino

I want to read data from any of the usb ports, with the arduino. From what I have read, you have to know to which port you conect the arduino to, to read data, but I want to be able to read data from any port the arduino is connected to.
Can someone please tell me how to do this?
Thanks in advance!

Can someone please tell me how to do this?

I have a bank of phones. I only want to answer the phone if it is my friend Joe calling. How can I do that?

You can’t. You have to know that the Arduino is connected to the port you are opening, or you have to open the port and ask if the Arduino is on the other end. Of course, in order to do that, the Arduino must be expecting the question, and provide the appropriate answer AND any other application already on the port can not be disturbed by your intrusion on the port.

PaulS:

Can someone please tell me how to do this?

I have a bank of phones. I only want to answer the phone if it is my friend Joe calling. How can I do that?

You can't. You have to know that the Arduino is connected to the port you are opening, or you have to open the port and ask if the Arduino is on the other end. Of course, in order to do that, the Arduino must be expecting the question, and provide the appropriate answer AND any other application already on the port can not be disturbed by your intrusion on the port.

I get the impression that he wants to use his Arduino like a memory stick. Plug it into any USB port on any computer and read the data from it. As you said, it can't be done.

Strictly speaking the Arduino (Uno or Mega for example) neither knows nor cares what USB port it is connected to.

It is the PC software that has to know what USB port the Arduino is connected to.

...R

what kind of data are you thinking on reading? What are you trying to do?
If you want to read serial data, there is some very good info about it (with examples and all) on the reference.
Here is the main page for the Serial:
http://arduino.cc/en/Reference/Serial
and then on the right side you can choose and learn about some very useful functions to read data coming from serial…
:wink:

here is an example of reading data from serial:

int incomingByte = 0;   // for incoming serial data

void setup() {
  Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop() {

  // send data only when you receive data:
  if (Serial.available() > 0) {
    // read the incoming byte:
    incomingByte = Serial.read();

    // say what you got:
    Serial.print("I received: ");
    Serial.println(incomingByte, DEC);
  }
}

the example was taken from this page:
http://arduino.cc/en/Serial/Available

we check if the Arduino got some data and, if yes, we store that data into the incomingByte variable.
Then we can do whatever with that information, in this case it is being printed (in decimal)…

:wink: