port register/PIND & PINB read gone awry

so i try to capture the states of input pins PIND and PINB in a byte array, and i'm trying to filter the results with a switch/case. the problem i'm having is that the byte containing PIND's value is only returning 6 bits, and the byte containing PINB's value is only returning 4 bits. when i serial.print (PIND, BIN) directly, i receive all 8 bits. i don't get it... what am i doing wrong?

byte test[2];
char* returned[2];


void setup()
{
  DDRD = B00001000;  //set all port d to input, leaving serial ports alone.
  DDRF = B00001100;  //set port f to input
  PORTD = PORTD | 11010011;  //enable pullups on portD. PD5 missing?
  PORTF = PORTF | 11110011;  //ditto port F pullups.  PF2, PF3 missing?
  Serial.begin(9600);
}

//blah, blah, blah 

void loop ()
{
  test[1] = (PIND, BIN);
  returned [1] = pinD();
  test[2] = (PINF, BIN);
  returned [2] = pinF();
  Serial.println(test[2], BIN);
  Serial.println(test[1], BIN);
  delay(1000);
}

//blah blah blah

char* pinD ()
  {
    test [1] = (test[1], BIN) | B00101100; //set values of rx/tx to 0 for easier processing
        switch (test[1])  //process button presses
        {
          case B11111111: //nothing pressed
            return ("n");
            break;          

          //...

         default:
          return ("?");
          break;
          
      }
  }

char* pinF ()
{
 test [2] |= B00001100; //set values of rx/tx to 1 for easier processing
  switch (test[2])  //process button presses
    {
    case B11111111: //nothing pressed
    return ("n");
    break;


   //...
    
    default:
    return ("?");
    break;
    
  }
}

what am i not getting?

  test[1] = (PIND, BIN);

What is this? I'm pretty sure it isn't doing what you think it is.

Ditto here:

    test [1] = (test[1], BIN) | B00101100;

Try this sketch:

void setup ()
  {
  Serial.begin (115200);
  Serial.println ();
  int i = (8, 10);
  
  Serial.println (i);
  }  // end of setup

void loop () { }

What do you think it will print? What does it actually print?

thanks for your help.

  test[1] = (PIND, BIN);

i was under the impression that it would store the reading of port d input's states in the first position in my byte array, in binary format

     test [1] = (test[1], BIN) | B00101100;

^ this was supposed to use a bitwise or to change the value of the bits marked 1 to a 1 while leaving the value of the bits marked 0 as they are.

i just now got this to work by changing it to

test[1] = PIND

in the loop and

test [1] |= B00101100

in the pind function
why is that? what was it doing before?

i thought it might print "8, 10", but it printed 10.
why's that?

tooandrew:
thanks for your help.

  test[1] = (PIND, BIN);

i was under the impression that it would store the reading of port d input's states in the first position in my byte array, in binary format

Interestingly enough, I just did a write-up about storing data "in binary format":

i thought it might print "8, 10", but it printed 10.
why's that?

Look up the C "comma" operator.

tooandrew:
thanks for your help.

  test[1] = (PIND, BIN);

i was under the impression that it would store the reading of port d input's states in the first position in my byte array, in binary format

That is actually the second position of the array. Arrays in C start at zero.

byte test[2];
...
  test[2] = (PINF, BIN);

Therefore this statement overwrites some memory that you don't want overwritten.

tooandrew:
i was under the impression that it would store the reading of port d input's states in the first position in my byte array, in binary format

ALL data in an Arduino is stored in binary. There is no need to convert it.

...R

The comma ',' has various uses in C/C++, one being the separation of parameters
to a function call or definition, another being separating array elements in an
array initializer list, but otherwise the comma is an operator that discards its
left hand side value after evaluating it for side-effects. So what

  (PIND, BIN)

does is read the PIND register, discard that value, then return the
value of BIN, which is an enumerated or #define constant whose actual value is
uninteresting.

When you see

  Serial.print (PIND, BIN) ;

You have a function call to the Serial print method passing two arguments, since the
argument list is "PIND, BIN". Do this:

  Serial.print ((PIND, BIN)) ;

And you'll be using the comma operator, passing a single value, BIN, to Serial.print.