Global variable not sticking

This is one of those things that works in C but really shouldn't.

  if(sensorOrPen == pen) {

The compiler thinks in types. If you break this down into types then you have...

  if(boolean == enum_I_just_created) {

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.

Declare the enum type in global scope. sensorOrPen should be that type. Then you can sensibly compare it to values in the list or other variables of the same type.

Or do it the C++ way, where you can 'overload' the equality operator to do whatever you want with your special type you just created. True might be 'equal' to the third item on the list if you want.