- Sun Sep 16, 2018 2:33 pm
#78257
take any wire (like a breadboard wire) and tap it several times to GPIO12. Do not connect the wire to anything other than tapping the GPIO12! Does the LED turn off??
No. Yes. Sometimes. It depends on the charge on the wire and how that compares to the potential of the input.
If I were to be in contact with the wire, I then use the wire to touch VCC, I make myself the potential of VCC. I then touch the input pin and there is no change. I am at a logic high.
But if I instead ground myself to the metal case covering the ESP module (I used a ESP-M3) and then touched the input with the wire (still in contact with my body) the blue led goes off. As expected.
I am part of the circuit and I hole a lot of charge. Just with a bare wire, well insulated, 22AWG, 2 feet in length, I can repeat the above test, ground the wire then use it to touch the input, and it only rarely turns off the blue led. The charge on the wire mostly can't overcome the pull up resistance. But this is if I had the charge on the wire at circuit ground potential. If I had the charge as being more negative then it would have a stronger likelihood to cause the input to see a low state.
You need to understand that everything has a potential and a charge and sometimes they become relevant in our circuits. With that understanding you can then decide if they are significant or not.
Debounce routines are useful but they are not always a proper fix. It is much better to understand the underlying cause and then to make the best decisions given the situation. It can be far better to include a RC delay on a pin set for interrupts, to deal with high frequency noise, than to try and fix it in software. There is no best one solution. There are always tradeoffs.