here are some functions that I find useful for this kind of thing:

`const int maxBits = 1024; // the number of bits to store (make this evenly divisible by 8)`

unsigned char bitData[maxBits / 8]; // uses 128 bytes to store up to 1024 bits

// stores the given bitValue using an index ranging from 0 to 1023

void writeBitArray( int bitIndex, boolean bitValue)

{

int arrayIndex = bitIndex / 8;

bitWrite(bitData[arrayIndex], bitIndex % 8, bitValue);

}

// returns the bitValue stored at the given index

boolean readBitArray(int bitIndex)

{

int arrayIndex = bitIndex / 8;

return bitRead(bitData[arrayIndex], bitIndex % 8 );

}

useage:

writeBitArray(i, bit); // save bit in location given by i

readBitArray(i); // return the bit value at location i