sending 32 bits wirelessly Solved

I usually send the settings of bcd switches via virtualwire or easytransfer, with a separate byte for each switches 4 bits.

One of the projects I am on now has 24 switches that I must send the position of. I need to end up with 32 outputs to drive individual solenoid drivers.

I could waste a whole byte for each switch, but it I am thinking I could sample each switch ( I have 4 CD4017s stepping through the switches ) and send them as 3 bytes

I could then take the 1 or 0 for each switch, and move the bit one place to the left, and so on, in 3 batches, so I would end up with 3 bytes to send.

I basically do this with my bcd switches, so I can sort that out, but I am not sure of the best way at the receive end, to separate the bits from the bytes.

I can probably come up with an overcomplicated method of generating 0000001 and bitwise and it with the received byte, then 0000010 and so on, but I am sure there is a simpler way ?

OK I have just found bitread()