I want to read the state of a switch sensor (magnetic contact). I'm thinking to connect the switch between an interrupt pin of my micro and ground, listening for CHANGE status. In this way I have debounce problems, so I wonder what's the best way to deal with this problem:
1 - Disable the interrupt listening when it fires and enable it after the program has read the value (0 ->ground->switch closed OR 1->floating->switch opened) I don't think a floating state could be good, but if I set the interrupt input pin as INPUT_PULLUP it's no more floating and could be good, am I right?
2 - Connect the switch to an interrupt pin and also to a digital input pin through a transistor as a switch. In this way, when the interrupt is triggered I read the value of the digital input pin. On the other hand, in this way I complicate the circuit
3 - To use an hardware debounce circuit
Are these three solutions valid? Are there any more better than these?
MORE CONTEXT: I'm using these switches as limit switch for a garage door. In my code I'm using a timer to raise the garage door for ten seconds OR until the limit switch interrupt is triggered
EDIT: with a change in my code I solved the problem using interrupts. However you suggest to use polling since it's not a real-time application, so I wonder: isn't better the same to use interrupts so that I can use a power safe mode for my micro and wake-up it only when an hardware interrupt is triggered? If i use a polling solution the system would not be suitable for battery power supply; isn't it?