How do I use variables in functions/procedures

So each row has a single non-zero value, which is itself a power of two; so that consecutively, they are also a bit-wise expansion of single byte, for a given "chip"? (And those bits are always contiguous? Do you ever need to send zero?)

led5 through led10 is

  • 4 + 8 + 16 + 32 + 64 + 128, or
  • 0b11111100, or
  • 252 in the middle, or third chip

Followed by

  • 63 in the last chip (or is that the "first" chip, as per the comments in post #1?)
  • 12
  • 192

This could be expressed more directly, maybe like:

enum Chip : byte {_1ST = 1, _2ND, _3RD, _4TH, LAST};

struct Foo {  // no idea what to call this
  Chip chip;
  byte value;
};

Foo leds[] = {
  {_3RD, 252},
  {LAST, 63},
  {_2ND, 12},
  {LAST, 0b1100'0000},  // or use the bits directly
};

void doWhatever() {
  for (Foo &f : leds) {  // loop through them all
    Serial.print(f.chip);
    Serial.print('\t');
    Serial.println(f.value);

    bool firstBit = false;
    for (int m = 0; m < 8; m++) {
      byte mask = 1 << m;
      if (mask > f.value) {
        break;
      }
      byte bit = f.value & mask;
      if (bit || firstBit) {
        firstBit = true;
        for (int c = _1ST; c <= LAST; c++) {  // easy to reverse chip order
          Serial.print(f.chip == c ? bit : 0);  // replace with shiftOut()
          Serial.print(c == LAST ? '\n' : '\t');
        }
      }
    }
  }
}

void setup() {
  Serial.begin(115200);
}

void loop() {
  doWhatever();
  delay(2500);
}

which prints

3	252
0	0	4	0	0
0	0	8	0	0
0	0	16	0	0
0	0	32	0	0
0	0	64	0	0
0	0	128	0	0
5	63
0	0	0	0	1
0	0	0	0	2
0	0	0	0	4
0	0	0	0	8
0	0	0	0	16
0	0	0	0	32
2	12
0	4	0	0	0
0	8	0	0	0
5	192
0	0	0	0	64
0	0	0	0	128

which is the data you had originally. Instead of just printing the derived bit values, call shiftOut