This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I was playing around with some old buttons on my oscilloscope to see how much bounce they had and though I would share my findings. I found a couple interesting posts I plan to try out; A nice looking software solution called OneButton (credit to u/MikeMitterer in this post) which seems slicker then my own debouncing implementation, and a hardware solution. I'm excited to try the hardware one as I have always used software to debounce.
In any case, when I first saw why you need to debounce a button, it was a real eye opener. It can also give you a clearer idea of how long to debounce for. In fact, after this demo, I now have a debounce time of 20ms instead of 15ms. The pictures here show why.
This image shows a single click of an old arcade game switch that had been around for about 10 years. From the time I press it to the time I let go is just shy of 100ms. I have a pull-up on my switch, so the signal is normally high, and when the button is pressed it goes low. Each square in the grid from left to right represents 10ms. The horizontal dashed line shows where a logical 1 transition’s to a logical 0, or a 0 to 1. Anything above the line is a 1, anything below is a 0.
Note that the line is at 2.5V, I believe the logic level is 2.4V. But it doesn't change the outcome of this sample.
Zoomed into where I press the button, you can see several spikes where it goes down, then back up. If this was hooked up to an ESP32, it would have read several rapid button presses. 7 in fact. It took the button about 16.08ms to settle into a solid down state.
Zoomed into when the button was pressed
A similar situation occurred when I released the button. In this case, it went up and down twice before settling into a stable up state. It took 9ms before it was stable.
Zoomed into when the button was released
So as you can see, always debounce your buttons. Some of the newer buttons won't need as much debouncing, but you'll find most do need at least some.
I didn't have an ESP32 attached at the time. I’ll have to follow up with one attached running with hardware and software solutions.
Subreddit
Post Details
- Posted
- 1 year ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/esp32/comme...