Debounce Code – one post to rule them all

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: debounce@hackaday.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.

[Read more...]

Waterproof DIY momentary-push switch

[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.

Open Call: send us your Debounce code

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.

Send your debounce code to: debounce@hackaday.com

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.

[Read more...]

Build a simple switch

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.

[Thanks Michael]

Pure TTL based clock

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. [Read more...]

Shadow buttons

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.

[Read more...]

Push potentiometer from spares

ppot

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].

Follow

Get every new post delivered to your Inbox.

Join 96,425 other followers