There are a couple of problems in this bit of code:
digitalWrite(data, !!(table[k] & (1 << pos))); //data= data output pin , Outputs each single bit (MSB)
if (pos=0) { //when all bits are sent it switches channel
pos=16;
when pos is 16, 1<<pos will equal zero. You need to initialize pos to 15. I would also change the way that you select the bit in digitalWrite. Finally, "if(pos=0)" doesn't test for equality, it sets pos to zero.
So, initialize pos to 15 and then replace the above with this:
digitalWrite(data, (table[k] >> pos) & 1)); //data= data output pin , Outputs each single bit (MSB)
if (pos == 0) { //when all bits are sent it switches channel
pos = 15;
Pete