How can I detect HIGH or LOW input on a NXP microcontroller?
Your code is not correct. b1 = P1^0 means P1 XOR 0. Anything XOR 0 gives the original value.

To assign bit 0 to b1, you need to write b1 = P1 &amp; 1, or preferably:

b1 = P1 &amp; (1&lt;&lt;0)

The latter form is universal, to get bit 1 you'd write 1&lt;&lt;1. For bit 2, you'd write 1&lt;&lt;2, and so on.