loop through shift register with random values

Hi all,

I've been working for hours on this code but I can't get it to work. Here's what I want to do. I've got 3 boards with 8 LEDs. I want to light the rows of LEDs randomly starting with the outermost LED. The result would be something like: (x=off, O=on)
xxxOxxxx
xxOxxxxx
xxxxOxxx
Later on in the code I want to work back using a timer and that the result would be:
xxOOxxxx
xOOxxxxx
xxxOOxxx
next step:
xOOOxxxx
OOOxxxxx
xxOOOxxx
etc.
At the moment I'm already having problems with turning on all the outmost LEDs. Here's my code:

// array that holds all the low values
long rand_low[3]={1, 1, 2}; // will be random numbers later
byte all_bytes[3][8]; // bytes for 3 displays
byte data_array[8]; // byte values
//byte data_array_O3[8];
byte data;
// loop data per gas
byte data_O3;
byte data_CO;
byte data_NO2;
void setup()
{
  Serial.begin(9600);
  data_array[0] = 1;
  data_array[1] = 2;
  data_array[2] = 4;
  data_array[3] = 8;
  data_array[4] = 128; // order has changed
  data_array[5] = 64;
  data_array[6] = 32;
  data_array[7] = 16;
  //fill 3 arrays with bytes
  for (int x=0; x<a_length; x++){
    for (int y=0; y<8; y++){
      all_bytes[x][y] = data_array[y];
    }
  }
}
void loop(){
    // turn on outer most rings
    for(int i=0; i < a_length; i++){ 
      Serial.print("i=");
      Serial.println(i);
      // loop through array, turn on one by one
      for(int j=0; j<=rand_low[i]; j++){ // low pollution 
        data_O3 = all_bytes[0][j];
        data_CO = all_bytes[1][j];
        data_NO2 = all_bytes[2][j];
        my_shiftout(data_O3);
        my_shiftout(data_CO);
        my_shiftout(data_NO2);
        Serial.print("j=");
      Serial.println(j);
      }
    }
    }
// FUNCTION my_shiftout(binary data); central function for controling displays
void my_shiftout(byte d){
  digitalWrite(status_led, HIGH); // turn on and off while shifting
  //Serial.println(d, HEX);
  // send byte
    Serial.println(d, BIN);
    shiftOut(DATA,CLOCK, MSBFIRST, d); 
    digitalWrite(status_led, LOW);
    // turn dispay on
    strobe();
}
void strobe()
{
  digitalWrite(STROBE, HIGH);
  delay(1);
  digitalWrite(STROBE, LOW);
}

This generates this output:
i=0
shifting 1
shifting 1
shifting 1
j=0
shifting 10
shifting 10
shifting 10
j=1
i=1
shifting 1
shifting 1
shifting 1
j=0
shifting 10
shifting 10
shifting 10
j=1
i=2
shifting 1
shifting 1
shifting 1
j=0
shifting 10
shifting 10
shifting 10
j=1
shifting 100
shifting 100
shifting 100
j=2
And I expect the LEDs to be turned on like this:
xOxxxxxx
xOxxxxxx
xxOxxxxx
But they are turned on like this:
xxOxxxxx
xxOxxxxx
xxxOxxxx

My question is where the error is. Is it in the arrays with bytes or in the looping? Could someone please take a look at my code and point me in the right direction. Thanks so very much in advance for you help and time. Best, Danielle.

xxxOxxxx
xxOxxxxx
xxxxOxxx
Later on in the code I want to work back using a timer and that the result would be:
xxOOxxxx
xOOxxxxx
xxxOOxxx
next step:
xOOOxxxx
OOOxxxxx
xxOOOxxx
etc.

I might be tired or something but what comes after "etc"? Starting from the top?
Is the pattern some kind of "knight rider" (or Battlestar Galactica Cylon robot eye:-P)-thing, that grows wider and wider until the hole row is filled? You depict it starting from the middle, but describe it starting from the ends?

And something is lacking from the source, variable a_lenght (=3,right?) and one more I think. Makes me think this is just a little extraction, except it seems pretty complete.

Anyway, your pattern at the end is just shifted one bit to the right of what you excpected?

Maybe if you describe what you want to do in another way?

As for your three identical arrays, to make them more like your pattern you could do this (if you want to do it like this, storing them in an array that is. Take into consideration I don't really know what you want to do though...maybe I'm far off - Also, not tested):

  //fill 3 arrays with bytes
  for (int x=0; x<a_length; x++){
    for (int y=0; y<8; y++){
      all_bytes[x][y] = data_array[y];
      for (int widen=0; widen<y; widen++){
         all_bytes[x][y] |= (data_array[y] << widen);
      }
    }
  }