How do I transform data for a column to data for a row, for a led matrix
You use a mask 10000000. With each iteration of the outer loop the 1 in the mask is shifted to the right. 01000000 -&gt; 00100000 -&gt; 00010000. Let's say we are in the 2nd iteration the mask is 01000000. x = x | (valueVector[p] &amp; mask); takes the 2nd bit (counted from left) and sets it at the 2nd position in the x value. But this position contains the bit from the last iteration (as you shifted it to this position).
Possible solution: (I have no compiler at hand. So hopefully it is correct. ;-)
byte x;

for ( int j=0; j&lt;8; j++ )
{
   x = 0;

   for ( int p=0; p&lt;8; p++ )
     x = x | ((valueVector[p] &amp; (1 &lt;&lt; p)) &gt;&gt; p);

   lc.setRow(0, j, x);
}