Global variable not sticking

6v6gt:
If subscript x has a value of 2 or more, the array positions[2] will over flow and corrupt other memory space, maybe causing the phenomenon you have experienced.

Sorry, I forgot to include that x is an enum for the axis (x or y).

MorganS:
This shouldn't be a valid expression. How do you compare true and false to an unlimited list of things with unlimited meanings? It "just" works because they're really integers behind the scenes and the compiler lets you get away with this for historical reasons.

I tried making sensorOrPen of typdef byte thinking along a similar train of thought to yours, but it gave no change in results.