Port D isn't Working as Input I'm using an Atmega328p SMD with 32 pins.  I'm trying to get several pins on Port D to function as inputs.  As outputs, they work fine, but for some reason, not as inputs.  Here's a simple example of what I'm dealing with.

void setup() {

DDRB |= (1&lt;&lt;PB3);  //Set up an output on PB3 for an LED
DDRD = B00000000;  //All of Port D set as inputs
DDRC = B00000000;  //All of Port C set as inputs
}

void loop() {

int Power = (PIND &amp; (1 &lt;&lt; PORTD5));  //Read input

  if(Power == 1){
PORTB |= (1 &lt;&lt; PORTB3);      //set high
  }
  else{
  PORTB &amp;= ~(1 &lt;&lt; PORTB3);  // set  low  
}    


I get no response from my LED like this, no matter which pin on Port D I use as an input.  But when I simply change over to Port C, it works fine.

int Power = (PINC &amp; (1 &lt;&lt; PORTC5));  //Read input


Ideas?
You check if power is 1, but it will never be 1. Instead it will be 1&lt;&lt;5 or 32. Better use:

if(Power != 0){
  PORTB |= (1 &lt;&lt; PORTB3);      //set high
}
else{
  PORTB &amp;= ~(1 &lt;&lt; PORTB3);  // set  low  
}