I've seem a youtube video recently. The host said, that PUSH_BUTTON make noise because of so called "Bouncing effect". He said, that this effect produces noise. He said, that IC's do not like noise in general.
So, my question to you: does an ESP8266 12E need a capacitor for a push-button (see shematic). And if yes: which type and load should I use ?
Are you sure you have problems with contact bounce. Your diagram shows the button wired between 3.3volt and input, without pull down resistor. That will surely result in a 'floating' pin, with unpredictable results.
You could use a pull down resistor, but there is an easier way. Wire the switch between pin and ground, with internal pull up enabled on the pin in setup(). pinMode(buttonPin, INPUT_PULLUP);
Inverted logic now. Button pushed == LOW, not pushed == HIGH.
If debounce is needed or not depends on the rest of the code.
Leo..
If you wire your push button to ground, and set the GPIO13 as input-pullup you can debounce it with a capacitor to ground as explained here; which also explains why that configuration is better.
The input pullup resistor is generally between 20-50k (except the due) so an 0.47uf cap gives a time constant of 10msec - more than enough to debounce any normal switch.
If the code doesn't read the switch again within the bounce time, or doesn't care if the button is not pushed after triggering, then forget about using debounce code.
Leo..
Yes, I can do it too. But I've heard, that this effect damages the IC (ESP) in general.
Sorry dude, I made a mistake in that circuit. There should be placed a 10K resistor. Look at my shematic again now.
Secondly: I have no problem with my code right now. I said in the first post: "I've heard, that this effect can damage the IC. Therefore, I asked you wheather this is true, so is it ?
Okay falks, let me be clear: I've currently now problems or issues with my circuit. I said, that I have only heard, that using a PUSH_BUTTON without a capacitor can damage any microcontroller. That's what I wanted to ask you, so, is this true ? Should I use a capacitor ? If yes: which kind of Capacitor ?
No, the opposite can be true.
The cap discharges through the pin when you turn off power to the MCU.
If the cap is too big, that discharge could damage the pin.
No cap, no discharge, no damage.
Leo..
okay falks, the reason why I started this conservation in the firstplace, was this video I randonly saw on Youtube:
In Minute 12:48, he is saying, that these bounces will disturb the microcontroller. This shocked me. To be clear: I only use this button as a simple DC-MOT run/stop Button.
shows two rotary encoder switches being debounced with an rc network each. One resistor, one small capacitor.
A bouncing input will not damage a microprocessor. Perhaps what the video meant by "disturb" is the truth that bouncing will mess up an algorithm that depends on stable switching.
added: yes, he said annoying and disturbing. Which is correct. He said nothing about damage. Just being colorful and poetic I guess. Microprocessors do not get disturbed or annoyed. We, on the other hand, can be both by bouncing switches.
If you do cheat (it's not cheating) and take the hardware route, it is preferred to use a real resistor. The internal pull up effect is a bit weak; more importantly is that by specification it can have a wide range. For consistency use a real resistor where shown.
"Disturb" is probably the wrong word.
A bouncing switch can only upset execution of the code, not damage the processor. A bouncing switch can make the code do things several times, when you only want it done once. Debounce code ignores button presses for a set time after the button has been pressed, thus ignoring bounces.
Leo..
@alto777@Wawa thanks to both of you. If I could, I would mark both as solution. Tanks to both of you, and to all others too.
Problem solved. My code is working absolute fine dispite that tiny bounces. I was born with coding, so therefore, I am confidend that my code works well