If you’ve run out of I/O pins on a project and need a way to add user input you can find a slew of port expanders that work with various communications protocols like I2C and 1-Wire. But if you just want to add in some buttons without reaching for an extra IC you’ll love this hack. [John Boxall] shows how to add four buttons using one ADC pin.
The concept is nothing new. The buttons make up an R2R resistive ladder. When one of them is pressed, it completes the circuit for a voltage divider. The results are measured by the analog-to-digital converter of an IC to tell which button was pressed. The difficult part is calculating the resistor values. [John] is using eight resistors made up of just two different values. Every button and every combination of buttons has a unique voltage result which can be discerned by the chip. He even made a truth table so you don’t have to.
The example circuit seen in the video after the break uses an Arduino. But this concept is directly applicable to any microcontroller. And it should be quite easy to use an ADC interrupt to drive all of the button-read events. Continue reading “R2R ladder connects multiple buttons to one ADC pin”
One of the perks of writing for Hackaday is that we often find hacks that we’ve been meaning to do ourselves. Here’s one that will let us fix our borked ASUS computer monitor buttons. [Silviu] has the same monitor we do, an ASUS VW202, and had the same problem of stuck buttons. We already cracked ours open and realized that the buttons are not easily replaced (you’ve got to source the right one). We just unstuck the offender and vowed not to press that button again, but [Silviu] actually figured out how to disassemble and repair the PCB mount switches.
As with most consumer electronics these days the worst part of the process is getting the monitor’s case apart. The plastic bezel has little spring tabs all around it that must be gently pried apart. Once the PCB which hosts the buttons was removed, he took the metal housing off of the broken switch. Inside he found that a bit of metal particulate (leftovers from manufacturing?) were causing the problem. A quick cleaning with a cotton swab removed the debris and got the tactile switch working again.
A system is only as strong as its weakest link and [Roberto Barrios] found that on the sixth generation iPod nano the buttons are the problem. It makes sense that the buttons would be exposed to wear since they’re movable parts. The issue isn’t one of contacts or springs wearing out, but how the buttons are assembled. Each consist of a couple of parts; the tactile piece that you see and press, the electrical switch which converts that force into an electrical signal, and a shim that bridges the gap between the two.
After two months of use the iPod [Roberto] was fixing had stopped responding to presses of the Power button. It turns out that the shims are attached with double-sided tape. Inspection of the internals revealed that the shim had slid to one side and no longer made contact with the electrical system. His solution was to remove the tape and clean off the goo, then reattach the shims using “two-part metal cement”.
With the shim back in place all is well but he made sure to execute this fix on all of the buttons before reassembly.
Yep, if you’ve got a button that needs pushing, this is one way to do it. [Travis] combined an old alarm clock with a car door-lock actuator and minimal logic circuitry to make this happen. When the alarm time is reached, the adjustable actuator comes down to press whichever button has been placed under it. In the video after the break he’s using it to schedule the start time for his Roomba, make his coffee, heat his pizza, or pointlessly press the clock’s own snooze button (classic). We think this is just begging to be used with a Rube-goldberg setup, perhaps to topple to dominos that other robot took the time to set up. Oh wait… that shows up in the video too. Fantastic!
Continue reading “This hack really pushes our buttons”
Last month we asked you to send in your debounce code. You didn’t disappoint and it’s time to share the code received. There were some guideline for sending in code so if you don’t see yours here, it probably didn’t follow the rules, sorry. We also tried to weed out code that using delay loops for debounce. These tend to be a poor way to handle inputs because they monopolize the processor.
We wanted to add upvote/downvote buttons to each set of code to give some idea of a group consensus on code quality but there’s no good system available for multiple up/down vote widgets on one wordpress page. This results in a huge code dump for any one person to go through. If you’ve got any ideas on how to better organize this let us know: email@example.com.
We make no guarantees that this code is safe to use, or that it even works. Test it carefully before using for important tasks.
Join us after the break for a whirlwind of code examples.
[Patman2700] has a nice scope for his paintball gun that uses a red dot instead of cross-hairs. The problem is that he kept forgetting to turn it off which ended up running the batteries down frequently. His solution to the problem was to get rid of the toggle switch used to turn it on and replace it will a home-made momentary push button switch. Now he presses the switch to aim and doesn’t waste juice when he’s running around, trying not to get pelted with paint.
Since this is used outside he wanted it to be water-tight. The switch is built using materials we’ve seen in previous diy switches; adhesive-backed copper sheets for conductors, foam to keep them separated until pressed, and plastic as a support. Copper is applied to the plastic base, with a ring of foam separating the base from the second layer of copper. When squeezed, the two layers of copper come in contact to complete the circuit. To make it work a bit better [Patman2700] added a dab of solder in the center of the bottom copper layer so there is less distance between conductors, and used extra foam to build up a bump in the center of the assembly for a better ‘button’ feel. The whole thing is encased in shrink-wrap with the seams sealed with super glue to keep moisture at bay.
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”