Another Shiftout question

I am trying to read 32 push button inputs and then serially output 32 bits to shift registers to control 32 LED's, which correlate to the 32 inputs. I would like any number of outputs to be on at once. I would like to store each input state in a 32 bit array: 1 for a button push and 0 for no button push. Any time there is a change in state of any button, the program should read all the buttons, store that states of each button somewhere and then output this to the shift registers and on to the LED's. My questions is about what to do between the bit read and the serial out to correlate the input to the output. I would like to get a 32 bit (4 byte) "string" that can be then shifted out but am not sure how to do that. I understand how to read inputs and shift out so I do not need any help on that. Any help is greatly appreciated.

I am trying to read 32 push button inputs

How?

http://arduino.cc/en/Reference/BitWrite will work on a 32 bit unsigned long.

@drhex Any examples of how to use the BitWrite, BitSet commands? I don't quite understand what they are trying to say. :-?

bitWrite etc lets you use an integer variable as an array of bits.

Something like this would let you store, on the same memory locations, an array of 32 bits and 4 bytes that you could shift out.

union {
    unsigned long bits;
    byte bytes[4];
} mydata;


for (byte i=0; i<32; i++) {
    bitWrite(mydata.bits, i, getInput(i));
}

for (byte i=0; i<4; i++) {
    shiftout(mydata.bytes[i]);
}

Well first you might want to figure out how you are going to read the 32 switches first. Unless you are using a mega board you will have to utilize some kind of input multiplexer chip(s), kind of like your output shift register only in reverse.

Lefty

I am using a multiplexer (x5) to read the inputs. I already figured out reading the inputs and the shift out, but just do not understand how to write the software in between. Thanks for your help.