Button Bouncing

Buttons can bounce? Oh, yeah! If you’ve ever tried programming a microcontroller, you most certainly have come across the problem: buttons can bounce.

This means that when you push a button, it goes from off to on, but sometimes it goes back to off again before going to on. This can happen several times within the first microseconds of a button being pushed. In digital circuits, this needs to be addressed.

I wanted to see what button-bouncing is all about. I’ve read about it, I know I need to take it into account when programming the microcontroller, but I hadn’t really seen it. Until now. Using my beloved oscilloscope I tested a few different buttons I had lying around. Buttons I typically use in various projects I’ve made. The results? See for yourself!

The figures below are examples of what button bouncing can look like when looking at the analogue signal. In a digital circuit (when a button is either on or off), things will look different depending on the cut-off levels for “on” and “off”.

First test: a 3A 250V breaker. Not really a button perhaps, but there is sill bouncing!

button bouncing 1

"Button 1" bounces for about one millisecond

Second test: a cheaper on-off switch

button bouncing 2

The on-off switch bounces too

Third test: a really cheap push-button, and one that I often use. Actually it behaved nicely most of the time, but sometimes there was a lot of bouncing going on… In the figure below it bounced around for about three milliseconds.

button bouncing 3

A clear case of button bouncing!

Fourth test: a more expensive push-button. And even tough I tried many times, it never bounced.

button bouncing 4

This button never bounced!

It’s interesting to see that one of my buttons showed no bouncing at all! No matter how quickly or slowly I pressed the button, it never bounced. It’s actually one of my favorite buttons, since it has an LED built into it. I’m not saying that it will never bounce, it probably will, just not today…

Even though this is not a scientific study, I think the results are interesting. At least it gave me a picture of what I have to deal with. Of all the buttons I pushed, on only a few occasions there was more than a few milliseconds of bouncing. In the Arduino de-bounce example code, it leaves a 50 millisecond bouncing window open. In my experience that is a lot. On the other hand, a person pushing a button won’t mind waiting 50 milliseconds, I guess.


Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.