If you’ve read Getting Started with Arduino you must have noticed that the circuit on page 43 uses a 10K Ohm resistor in series with the push-button. (If you haven’t read it yet, the example in the schematic on the right is similar to the setup featured on the book).
Consider a microcontroller with a digital input pin connected to a switch. When the switch is closed, the pin is connected to GND. When the switch is open, the signal is not connected to anything and is left at an unknown state. The signal is in this case said to be “floating”. This is pictured in circuit (1).
To remedy this problem we pull the signal up to VCC, as shown in circuit (2). Now when the switch is open the signal is connected directly to VCC and is at a known state. But notice that when the switch is closed, VCC and GND are connected, creating a short.
To prevent the short we place a resistor between the input pin and VCC, as shown in circuit (3). This resistor is called a “pull up” resistor.
Pull down resistors work almost in the same way, except the circuit is connected so that when the switch is closed the input pin is connected to VCC, and when switch is open the pin is connected to GND using a “pull down” resistor, as shown in circuit (4).
A common value for pull up resistors is 10k Ohm. Higher resistance may be necessary for circuits that sink greater currents. We can use Ohm’s Law to determine the appropriate value for the resistor.
You could just use the internal pull up resistors of the arduino when it is configured as inputs. Then you would just need the switch wired to the pin and ground. Right?
Right. I was actually not aware of the internal pull up resistors. Did some reading and found that setting the pin HIGH will turn that on for the pin. Seems that for simple switches the internal pullups are just fine, rendering the circuit on page 43 of Getting Started With Arduino redundant. Thanks, Chris!
Well, this is an epic epic fail.
I can not download the book “Arduino Programming Notebook” ebook by Brian W. Evans.