Modifications in function

  if ((level == 3) & (state == 0))

Should that be && in the middle? I can't see how a bitwise and is useful.

In your code, I can't see that changing the mechanism for triggering the switch will make any difference. The switches are still HIGH or LOW, regardless of what caused them to be HIGH or LOW.