I have a wireless reed switch which only triggers when its state changes, but I want to know what the state is - ie open or closed. I understand that I can create a global variable to track the state and update it wherever the reed switch is triggered, but it is easy to confuse by rapidly opening and closing the reed. Is there a better method for this?