Has anyone had issues with physical push button controls of programs?

gplus
(Ira T) #1

Has anyone had issues with physical push button controls of programs?
Any time I try and control a sequence, I always get a capacitive discharge feaux reading from my hand, and the button input reads High or Low before I even press it, leading to erratic behavior. I tried 5v with the resistor before and after the button, and both seem to give me errors.
Just wondering if anyone else has had this problem.
I’d like to use a physical button over electronic RF switching means.

(Andrew Tuline) #2

Sounds like a debounce issue. I use a button library which deals with that as well as provides ‘long click’ functionality.

(JP Roy) #3

Just about all mechanical switches bounce as they make contact AND break contact. Some cheaply manufactured switches can bounce for milliseconds !!
There are ways to deal with this in hardware but for most cases a software ‘debouncing’ function is the easiest and cheapest solution.
The Arduino IDE has built-in examples of simple switch debounce code.

(Ira T) #4

Even after trying the simple debounce programs just to turn pin 13 on and off, I still get the faux readings.

(Ira T) #5

Andrew, something like Button.h?http://playground.arduino.cc/Code/Button

(JP Roy) #6

I read your post more closely and realize you have something not really related to switch bounce if you are really getting a switch to change state before you even press it !?!?

(Ira T) #7

Yep. That’s what I’m dealing with (well, WAS dealing with about a month ago).

A friend of mine, who’s senior design project was a capacitance touch sensor, suggested that I add in a pF capacitor to offset any static charge that my hand might produce near the button.
Ultimately, the sequences ended up just being time limited, instead of using button control.

(Thomas Runge) #8

I’m quite satisfied with the OneButton library: https://github.com/mathertel/OneButton

Plus: it’s really free (read: BSD license, not GPL)

(Andrew Watts) #9

Just a quick question. Are you using the resistor as a pull-down/pull-up resistor, or is it in series with the button? Your original post has some ambiguity about the resistor, and if you have it in series it could be leading to this issue, as you have a line with a floating voltage that will pick up on things in its environment. Just covering the basics first

(Ira T) #10

Thomas: I’m gonna try that lib this week. If I can get something to work on a simple proggy, then it should work for all my needs. Thanks!

Andrew: I tried pull up and down, and the resistor before and after the button (both in series with the button though). I was using the 5v regulated output from the arduino board. We thought that there was some variance in the actual 5v, but it should still not have led to the “proxy sensor” problems occurring. :o/

(Andrew Watts) #11

So just to check, you’re wiring it like this: https://www.arduino.cc/en/uploads/Tutorial/button_schem.png I’m not meaning to push if you’ve already done this, but it’s really the only thing I can think of that would cause this kind of behaviour. If you have, I’d try getting a new button. Voltage regulators produce a very stable output, so shouldn’t be fluctuating

(Ira T) #12

Andrew: Yep. Tried different IN ports, and put the resistor before and after the switch IRT the input pin… also did pull up and pull down WRT the 5V or Ground supply.
(tried different buttons, and several Unos and Nanos as well)

(JP Roy) #13

@Ira_T
You claim to have tried different IN ports, , and put the resistor before and after the switch IRT the input pin… also did pull up and pull down WRT the 5V or Ground supply and tried different buttons, and several Unos and Nanos as well… and you still have a problem with switches changing state without actually touching them !!
Have you considered an exorcist ???

(Ira T) #14

I’ve thought to outsource the issue to a local televangelist… I figured he could do some sort of pay-by-tel healing thing for the circuitry… haven’t gotten around to making the calls yet though.

(Juergen Bruegl) #15

before you turn to those sources, can you post a pic of the button you are using?

(Ira T) #16

They’re the standard cheapo ones off of eBay.

(Juris Perkons) #17

Hello. I had similar “proximity sensor” by accident, when I actually needed button input there. Turned out my microcontroller input wasn’t configured as digital in. I guess it was analog in by default. That was why that pin acted like an antenna when my finger was approaching. Can not help with code, it was plain Atmel C, not Arduino. But maybe some food for thoughts.

(Juergen Bruegl) #18

I would make a blank wire sling and attach it with the nut to the switch; then connect it to ground.
Looks like you are highly ‘charged’. Low humidity, carpet etc. Try to discharge yourself to ground (touch the center screw of your wall outlet).
Also consider evil differences between mains earth and and ground on two pin power supplies. In other words: with 2 pin power supplies your ground is floating.
This video is not really related to static problems but explains the difference in grounds if you are using a laptop vs. a PC. Make sure you also watch from minute 17 - a real eye opener.