SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
User avatar
By Selenaut
#118719
I still don't get exactly how this works. Could someone please explain?
By esklar81
#118729
Selenaut,

I feel as if I've come into the middle of a discussion, as I don't have a clear understanding of what you "still don't get".

The usual approach is that you put a momentary switch between a DI pin and either Vcc or GND. You then provide a pull-up (if the switch is to ground) or a pull-down (if the switch is to Vcc) between the switch and the DI pin or use an internal pull-up or pull-down. When the switch is not pushed, the pull-up or pull-down provides the voltage seen by the DI. When the switch is pushed, the Vcc or GND is what the DI sees.

Also, you should read the material on "debounce' on the Arduino site.

Happy Hunting,
Eric
User avatar
By Selenaut
#118769
Thanks for replying. Do you know if there are certain values of resistrs that are good for this job? Or could I add different valued resistors to a number of buttons and connect them all to one analog pin?
User avatar
By leon_heller
#118772
That can work. Microchip mentions the technique in one of their Hints and Tips books.
User avatar
By Selenaut
#118787
Okay, I guess I'm going with the analog. Seems I can get more inputs that way. (I need about ten buttons to do a project idea I was thinking about, and I really didn't want to waste pins.)
By qema
#118819
Selenaut wrote:Okay, I guess I'm going with the analog. Seems I can get more inputs that way. (I need about ten buttons to do a project idea I was thinking about, and I really didn't want to waste pins.)
The only problem with the analog solution is that you cannot register multiple buttons at once, if you don't need multiple key presses then its a great solution.
Another solution that works even if you don't have an analog input. http://www.atmel.com/dyn/resources/prod ... oc2532.pdf