AtTiny85 reading from PIN
It all comes down to Operator precedence.

In C/C++, != is evaluated before &amp;. As a result, your condition is effectively:

if ( PINB &amp; (2 == 0))


Which it should be clear that this is always going to be 0 - 2 == 0 is always 0.

You have two choices:


Use something with a higher precedence in the if statement, for example ():

if ( (PINB &amp; 2) != 0 )


Which will work as expected - the parenthesis are evaluated before the !=.
Rely on the fact that any non-zero value is considered true:

if (PINB &amp; 2) //True is anything non-zero.