Go Down

Topic: Button Help Please (Read 511 times) previous topic - next topic

cozy2963

Hi everyone! I'm hoping that I might be able to find someone's help with what I keep doing wrong. I can't seem to make buttons work in anything other than a single circuit! I've attached pics of what I've been stuck on and what my board looks like after I've been struggling with it! Any help would rock. Thank you in advance.

septillion

Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

DVDdoug

Did you look at the Button Example?

If your button has more than 2 terminals, it may be wired wrong.    Not all buttons/switches are the same, so if you don't have a datasheet for the button, or a multimeter to test it, you may have to experiment with different connections.   As long as you have the resistor in series and as long as the Arduino pin is programmed as in input (not output) you won't hurt anything by wiring the switch wrong.  So, there's no harm in experimenting if there's more than one pin.

The example circuit works like this - The resistor "pulls down" the input to ground when the switch is open.   When the switch is closed, the switch's nearly zero resistance overcomes the pull-down resistor and the input is pulled-up to 5V (and as a side-effect, a small amount of current flows through the resistor).

The Arduino's ATmega chip has optional built-in pull-up resistors which can be enabled as described on this page.    When using the internal pull-ups, the switch gets wired to pull the input down to ground (and of course, you don't need, or want, the external pull-up resistor).    With the internal pull-up you may need to reverse the logic in your program/sketch, depending on if the switch is normally open or normally closed.    

Go Up