There is also also an extra 1k external pull up resistor.
I didn't see this happen before attachInterrupt() or after detachInterrupt(), but I can't say it doesn't happen. Is there any difference between a regular input and an interrupt input?
I've been searching for more info about it, but didn't find anything else but use pullup resistors. Any ideas what is going on, or how to fix it?
Note: this happens even with this pin disconnected.
Then you still may have problems with a large antenna in a hostile environment. Consider adding a capacitor as well, to form a RC low pass filter for that pin.
There is no need to ever detach an interrupt, especially in the loop function which starts with attaching an interrupt pin. And even this should not be in the loop function but in the setup function.
Also bush buttons like this should be wired across the diagonal to prevent any doubt about the orientation of the switch.
We only know what you tell us about your project d you are telling us very little. And half of what you have told us is wrong.
This code has 995 lines, so I am trying to simplify here.
Also, I am using a MEGA, not a UNO, but for schematic, I only have Uno availabe.
This project controls a step motor, a 16x2 Display and some other logics as well. stopLoop_funtion() has nothing more then those two lines.
I use detachInterrupt() because this button will be used to something else when this loop does not occur. It is in fact a CANCEL button on a keyboard, so it must to cancel this loop, but also navegate through menus.
At first, I tryed to use only one 100uF capacitor, but it was still floating too much, so I added a new capacitor, making an equivalent 570uF. If I am not wrong, it should be 1k * 570u = 570ms to discharge the capacitor. This seams incredibly high value, but belive it or not, the pin 19 is still floating!
Facing this situation, I decided to use the code below:
This way, I check if button is pressed when while loop reaches it's end. I fell this is not the correct solution, because if pin floats at this point, interrupt will be executed. It might be 99% fixed, but I want to fix it 100%.