How to check if a pin is set from bank? How would you go about checking if an input pin has been set using the entire bank? I am thinking that I need to use bit twiddling with a bit mask but I have not used this enough to figure out how to do what I want.

Basically I have the following code:

void setup() {
   DDRA = 0x00;
   PORTA = 0xff;
}

void loop(){
   //Check if any pin from Port A has been pressed
   if (PINA &amp; 0xff){
      //do stuff
   }
}


But the code above is not working how I expected it to. Has anyone tried to use this approach before? Am I going about this the wrong way? I figured since I was using all 8 pins from one bank, it would be better to check if any of the pins on that bank have been set instead of checking each individual pin. My thinking on this was to prevent any user input from being skipped in case a button press was initiated while the program was running other code. This way I only check if anything in the bank has been set saving time (I think).
The problem is here:


//Check if any pin from Port A has been pressed
if (PINA &amp; 0xff){



Since the pullups are enabled, the default state of the pins is high. To detect a "press", they have to be pulled to ground. This changes the test to:

//Check if any pin from Port A has been pressed
if (~PINA) {


And for individual pins:

//Check if PA3 has been pressed
if (!(PINA &amp; _BV(PA3))) {