Binary and integer management

Hi everyone, I am trying to figure out a way to mange LED states in the most efficient way for an LED cube. I know storing bytes of data will take much less memory than storing integers, but can't figure out how I'd begin working with them.

For example: one state of my LED cube can take 64 bytes minimum (512 bits) so 8 LEDs would be 1 byte such as B10101010, but when making an animation, I can't figure out how I would take a bunch of states (on or off) and turning them into binary. How could I make a bunch of individual states of 1 or 0 combine into B10101010? I'm also aware that I could write 170 to the same effect as B10101010, but I think that would be more difficult to troubleshoot and deal with.

How could I make a bunch of individual states of 1 or 0 combine into B10101010?

bitSet() or bitWrite().

thanks, bitWrite worked like a charm