Normally in C, any non-zero number will evaluate to true. If you want to check the value of a specific bit in your port, use the binary-AND operator &
. Note: Logical AND, &&
, and binary AND, &
, are not the same thing.
In your question, only PORTB will evaluate to false.
2
solved How binary numbers are evaluated for true or false? [closed]