If you’ve ever designed an embedded system with at least one button you’ve had to deal with button debouncing. This is also know as contact bounce, a phenomenon where a button press can be registered as multiple button presses if not handled correctly. One way to take care of this is with a hardware filter built from a resistor-capacitor setup, or by using a couple of NAND gates. We find that [Jack Ganssle] put together the most comprehensive and approachable look at contact bounce which you should read through if you want to learn more.
We’re interested in software solutions for debouncing buttons. This seems to be one of the most common forum questions but it can be hard to find answers in the form of reliable code examples. Do you have debounce code that you depend on in every application? Are you willing to share it with the world? We’d like to gather as many examples as possible and publish them in one-post-to-rule-them-all.
Here’s some guidelines to follow:
- Please only include debounce code. Get rid of other unrelated functions/etc.
- You should send C code. If you want to also send an assembly code version that’s fine, but it must be supplementary to the C code.
- Please comment your code. This will help others understand and use it. You may be tempted to explain the code in your email but this info is best placed in the code comments
- Cite your sources. If you adapted this code from someone else’s please include a note about that in the code comments.
As an example we’ve included one of our favorite sets of debounce code after the break. Please note how it follows the guidelines listed above.
Continue reading “Open Call: send us your Debounce code”
Forget hacking an easy button, grab a couple of those outdated CD-Rs and build your own switch for that next project. This was developed with handicapped accessibility in mind; assembled easily with common products and it’s fairly robust. In fact, our junk box has everything you need except the adhesive backed copper foil. Combine two old CD’s, covered in copper on facing sides, separated by two strips of Velcro to separate the conductors. When pressure is applied, one CD flexes to make contact with the other and complete the circuit. So easy, yet we never thought of it. We’ll add it to our list of homebrew input devices.
We’ll just say, [Kenneth] really likes clocks. His most recent is a pure 7400 series TTL based one, ie no microcontroller as seen in the past, here, here, and here. The signal starts out as a typical 32,768 crystal divided down to the necessary 1Hz, which is then divided again appropriately to provide hours and minutes.
As far as TTL clocks go, this is nothing too original; until it comes to his creative button interface. By using a not as sexy as it sounds multivibrator, he can produce a clean square wave instead of the figity signals produced from buttons to advance and set the time. Like always, he also provides us with a thorough breakdown of his clock, after the jump. Continue reading “Pure TTL based clock”
This art installation uses buttons made of light. A projector fills up the walls and ceiling of a room while a webcam monitors the pattern for changes. When the luminosity of a given area changes due to a shadow, a midi event is triggered. The software that controls the system is written in C# and uses the Emgu CV library to handle the image processing. In the video after the break you can see that creating shadows with your hands prompts changes in the image as well as the sound.
Continue reading “Shadow buttons”
In an effort to simplify his interface, [danwagoner] cobbled together this push potentiometer. It utilizes a potentiometer mounted directly above a push button with a spring mounted around it. This way the user has only one item to deal with. They can twist the knob and press down on it to push the button. We love seeing people come up with ways of creating their own items instead of buying something. This was fairly inventive and reminds us of the LED buttons we saw back in January. Great job [danwagoner].
[pros] has come up with a very elegant way of making lighted buttons (translated). Using a bunch of small push buttons harvested from old CD players, he rigged this unique way of mounting LEDs. Each LED has two buttons under it. They are wired in parallel, so if either of them is pushed, the button works. The LED isn’t actually soldered where it passes through the board. The anode and cathode are bent around and soldered to allow the LED a little bit of travel. There’s a good picture of how he did this on the site. The rest of the details might be hard to decipher though, it looks to be in dutch.
Electronics parts can be a pain to choose. It’s often hard to tell from manufacturers’ datasheets if a part will fit your design. We auditioned six different tactile switches to find a cheap button to use in upcoming projects. A tactile switch, also called a momentary button or push-to-make switch, is commonly used for input and microcontroller resets. This type of button creates a temporary electrical connection when pressed.
Footprints for most of these buttons are available in the Cadsoft Eagle library switch-tac, or in the Sparkfun parts library under TAC_SWITCH. Buttons in the image above are discussed from left to right. Continue reading “Parts: Tactile switches for your next project”