Bitshift help.

    b = 1 << 1 | 1;

Here you're assigning b to 0... temp times.

Try this:

for(byte i = 0; i < temp; i++)
  {
    b = b | (1 << i);
  }

There, every time the loop runs, b gets a 1 in one more place over.