Pages: [1]   Go Down
Author Topic: Button Halp!  (Read 505 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 4
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I uploaded the Button example, connected the button up to pin 0 and 2. Without touching it the led sometimes will randomly come on, I move it around and it will occasionally stay off and the button will turn the led on and off.
Logged

Connecticut
Offline Offline
Edison Member
*
Karma: 17
Posts: 1216
RTFD (Datasheet in our case)
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The arduino's input pins are very sensitive. Because of this, they can detect TINY amounts of current floating around in the air: that's your "random" part. We use something called "pull-down resistors" to fix this. Here's how you can use one:


5V-----Button------Input Pin
                     |
                     |
                10k ohms
                     |
                     |
                     |
                   GND


This causes all the random current to go to ground, and the pin sees 0. When you press the button, 5V can travel along the wire, and the pin sees 1.

(Don't worry if you don't understand it, just remember it)

Also: the resistor needn't be exactly 10k--that's just a common value. Any other resistor around that area should work.


Good Luck!

baum
Logged

Pages: [1]   Go Up
Jump to: