CONFUSED.

I have began investigating digital input output response of various things and started with the USB hub from a desktop DELL computer, one of those ones with the LED that changes between blue and orange.

I hooked up what was the connections to the hard drive and motherboard of the computer to 16 pins on my mega and wrote a sketch that designated a random state configuration and the read outs of 4 wires as inputs which where from a standard USB cable connected to the USB hub.

when i took a look at the serial monitor i notices that the input states didnt really change as randomly as i expected since each of the output’s state is a random variable.

The input state configuration seems to be more dependant on the delay time i put in the sketches loop.

I just want to understand because it was not the outcome i predicted.

void setup() {
    for(int Pin = 0;Pin < 4; Pin++){
    pinMode(Pin,INPUT);}
  for(int Pin = 22;Pin < 38; Pin++){
    pinMode(Pin,OUTPUT);

  }
  { 
    Serial.begin(9600);
  }
}

void loop() 
{
  int MyOutputState[] = {
    random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2),random(0,2)  };

   
  for(int Pin = 22;Pin < 38; Pin++)
  {
    digitalWrite(Pin,MyOutputState[22-Pin]);
  }
  int input0 = digitalRead(0);
  int input1 = digitalRead(1);
  int input2 = digitalRead(2);
  int input3 = digitalRead(3);

{
    Serial.println("");
    Serial.println("");
    for(int i =0;i<=15;i++){ Serial.print(MyOutputState[i]);
    Serial.print(" ");
    }
   

    Serial.print("    ");
    Serial.print((input0));
    Serial.print("    ");
    Serial.print((input1));
    Serial.print("    ");
    Serial.print((input2));
    Serial.print("    ");
    Serial.print((input3));

    Serial.println(" ");
    Serial.println(" ");
    delayMicroseconds(3);
  }
}

The output state config is the left 16 and the inputs are the 4 to the right in the screen shots of serial monitor. When the 4 inputs are put in the analog inputs of another micro controller the graph of their analog read wrt time shown is as expected with random pulses from 2 wires and constant pos and negative voltages for the USB power rails. so ill try and read more about baud rate to see if thats why the serial isnt picking them up.

I'm not sure I understand what you are attempting to achieve. If you plug anything into a usb hub, it will be totally ignored until you activate the appropriate pullup/down resistors that will tell the hub what speed you can run at. If you don't get this bit right, the usb hub will assume that you're just another battery charger and ignore you.

Even if you get that bit right, you will then have to respond wth appropriate signals to the handshaking that follows or you'll get ignored again. Simply probing around on a USB port is not likely to invoke a response.

Basically the outputs of my MC are the inputs for the usb hub (the ‘host’) and so im only getting a response from the hub when i set the delay time in the sketch to a value that corresponds with a bit rate that the usb hub accepts an initial packet from anything i connect to the usb hub’s ports. Is this right?

So am I to understand that you are trying to observe what’s occuring on the usb bus when a device is plugged into a host? And you’re attempting to achieve this by bit bashing the signal ines?