Interfacing switches with microcontroller
When examining a single bit in a byte (or register) using &amp; it's important to remember that the result of the &amp; will be a masked value, not the value of the bit you're interested in.

For example, if you have the value 0b10110101 in a register and you want to examine bit 2, you could mask it out with 0b00000100:

0b10110101
0b00000100 &amp;
==========
0b00000100 = 4


So the result is, in decimal, 4.  In your if statement you are comparing the results of the &amp; operation with 1.  That can only ever be true if you happen to be examining bit 0 in your register.

If you change your comparison either so it's comparing the masked value to the value of the mask then it can become true for the value you're actually examining.

Better still, drop the comparison altogether:

if (GPIOX_DATA &amp; 0xXX) // IF THE PORTS' DATA REGISTER, AT PIN, IS HIGH,
    GPIOX_DATA |= 0xXX;       // SET THIS PORTS' DATA REGISTER, AT PIN, TO HIGH


In an if comparison you're only interested in a true or false state.  In C a false state is defined as 0, and a true state is defined as any other value but 0.  So say the equation GPIOX_DATA &amp; 0xXX results in 4, that is a true value, since it's not 0.