user21114: 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<<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 & (1 << PORTD5));  //Read input

  if(Power == 1){
PORTB |= (1 << PORTB3);      //set high
  }
  else{
  PORTB &= ~(1 << 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 & (1 << PORTC5));  //Read input

Ideas?

user2881: You check if power is 1, but it will never be 1. Instead it will be 1<<5 or 32. Better use:
if(Power != 0){
  PORTB |= (1 << PORTB3);      //set high
}
else{
  PORTB &= ~(1 << PORTB3);  // set  low  
}


21114: <p>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.</p>

<pre><code>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  
}    
</code></pre>

<p>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.</p>

<pre><code>int Power = (PINC &amp; (1 &lt;&lt; PORTC5));  //Read input
</code></pre>

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

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