1 Introduction
Pull-up resistors are very common in microcontrollers or any digital logic device.
With a pull-up resistor, the input pin will read a high state when the button is not pressed. When the button is pressed, it connects the
input pin directly to ground.
Keep in mind, if the resistor wasn’t there, your button would connect VCC to ground, which is very bad and is also known as a short.
A low resistor value is called a strong pull-up (more current flows), a high resistor value is called a weak pull-up (less current flows). Usually
we use a resistor value of 10kΩ for the pull-up.
2 Conditions
The value of the pull-up resistor needs to satisfy two conditions:
1) When the button is pressed, the input pin is pulled low. The value of R1 controls how much current will flow from VCC to ground.
2) When the button is not pressed, the input pin is pulled high. The value of R1 controls the voltage on the input pin.
For condition 1, we do not want R1 is too low. However, for condition 2, R1 should not be too large. The general rule is to use R1 that is 1/10 less than the input impedance(R2). Usually a input pin on a microcontroler has an impedance that can vary from 100k to 1MΩ.
3 Calculating
Assume we want to limit the current to 1mA when the button is pressed, where Vcc = 5V. What resistor value should we use?
It is easy to show how to calculate the pull-up resistor using Ohm’s Law:
R1 = Vcc/I = 5V/1mA = 5KΩ
Another thing is that the larger the pull-up resistance, the slower the pin is to respond to voltage changes.