In my quest to understand electrical engineering, I have stumbled across this tutorial:


I have understood the diagrams until I got to switches. I am not sure how switches work on the breadboard or the diagrams. This is the specific one I am thinking of (this is of a pull down resistor):

enter image description here

The implementation is:

enter image description here

Based on the diagram, what I think is happening is: Power goes to the switch, if the button is up then the circuit is not completed. If the button is pressed then the current takes the path of least resistance to pin2 because it has more pull (100ohm < 10kohm).

The way it is described in the tutorial sounds like when the button is up, the circuit is still complete, but the 10k ohm resistor pulls the power to the ground. I am not positive how or why if both the 10k ohm and 100ohm are receiving equal current, the current would get pulled to the ground through a higher resistance than is open to pin 2.

  • 3
    \$\begingroup\$ An aside: try to think of a circuit in terms of what the voltage will be at each point, rather than where the current flows. This helped my understanding when I was first learning EE. \$\endgroup\$ Commented Aug 12, 2012 at 21:32
  • \$\begingroup\$ I'm kind of disappointed in the quality of answers on this question. I'd suggesting watching this video by AddOhms instead.. I don't understand this concept enough to explain it but none of the answers here at the time of writing are even talking about what causes the floating state, or how either pull-up or push-down resolves the problem. \$\endgroup\$ Commented Oct 16, 2015 at 20:55
  • \$\begingroup\$ @EvanCarroll On the other hand, the question at the time of writing doesn't ask about those things that you're interested in. \$\endgroup\$ Commented Aug 8, 2018 at 12:11

6 Answers 6


Firstly, forget the 100 Ω resistor for now. It's not required for the working of the button, it's just there as a protection in case you would make a programming error.

  • If the button is pressed P2 will be directly connected to +5 V, so that will be seen as a high level, being "1".
  • If the button is released the +5 V doesn't count anymore, there's just the 10 kΩ between the port and ground.

A microcontroller's I/O pin is high impedance when used as input, meaning there flows only a small leakage current, usually much less than the 1 µA, which will be the maximum according to the datasheet. OK, lets' say it's 1 µA. Then according to Ohm's Law this will cause a voltage drop of 1 µA \$\times\$ 10 kΩ = 10 mV across the resistor. So the input will be at 0.01 V. That's a low level, or a "0". A typical 5 V microcontroller will see any level lower than 1.5 V as low.

Now the 100 Ω resistor. If you would accidentally made the pin output and set it low then pressing the button will cause a short-circuit: the microcontroller sets 0 V on the pin, and the switch +5 V on the same pin. The microcontroller doesn't like that, and the IC may be damaged. In those cases the 100 Ω resistor should limit the current to 50 mA. (Which still is a bit too much, a 1 kΩ resistor would be better.)

Since there won't flow current into an input pin (apart from the low leakage) there will hardly be any voltage drop across the resistor.

The 10 kΩ is a typical value for a pull-up or pull-down. A lower value will give you even a lower voltage drop, but 10 mV or 1 mV doesn't make much difference. But there's something else: if the button is pressed there's 5 V across the resistor, so there will flow a current of 5 V/ 10 kΩ = 500 µA. That's low enough not to cause any problems, and you won't be keeping the button pressed for a long time anyway. But you may replace the button with a switch, which may be closed for a long time. Then if you would have chosen a 1 kΩ pull-down you would have 5 mA through the resistor as long as the switch is closed, and that's a bit of a waste. 10 kΩ is a good value.

Note that you can turn this upside down to get a pull-up resistor, and switch to ground when the button is pressed.

enter image description here

This will invert your logic: pressing the button will give you a "0" instead of a "1", but the working is the same: pressing the button will make the input 0 V, if you release the button the resistor will connect the input to the +5 V level (with a negligible voltage drop).

This is the way it's usually done, and microcontroller manufacturers take this into account: most microcontrollers have internal pull-up resistors, which you can activate or deactivate in software. If you use the internal pull-up you only need to connect the button to ground, that's all. (Some microcontrollers also have configurable pull-downs, but these are much less common.)

  • \$\begingroup\$ I don't think it's clear how the Push-Down method solves the problem with floating-state from this answer. \$\endgroup\$ Commented Oct 16, 2015 at 20:49

Note that the switch is not a fancy device that takes power and creates some output signal -- instead, think of it as a wire that you're just adding or removing from the circuit by pushing the button.

If the switch is disconnected (not pressed), the only possible path for current is from P2 through both resistors to ground. Thus, the microcontroller will read a LOW.

If the switch is connected (pressed):

  • Current travels from the power supply through the switch

  • Some current travels through the 100 ohm resistor to P2. The microcontroller will read HIGH.

  • A small amount of current will flow through the 10 Kohm resistor to ground. This is basically wasted power.

Note that the 100 ohm resistor is just there to limit the maximum current going into P2. It's normally not included on a circuit like this, because the microcontroller's P2 input is already high-impedance and will not sink much current. However, including the 100 ohm resistor is useful in case your software has a bug or a logic error that causes it to try to use P2 as an output instead. In that case, if the microcontroller is trying to drive P2 low but the switch is shorted and connecting it to high, you'd possibly damage the microcontroller pin. To be safe, the 100 ohm resistor would limit the maximum current in that case.


When you press the button you place a logic high level (+5 V) on the input. But if you omit the resistor and the button is released, then the input pin would just be floating, which in HCMOS means that the level is undefined. That's something you don't want, so you pull the input down to ground with the resistor. The resistor is required because otherwise pushing the button would cause a short-circuit.

The input is high impedance, meaning that there will hardly flow any current through it. Zero current through the resistor means zero voltage across it (Ohm's Law), so the 0 V on one side will also be 0 V (or very near) on the input pin.

This is one way to connect a button, but you can also swap resistor and button, so that the resistor goes to +5 V and the button to ground. The logic is then inversed: pushing the button will give a low level on the input pin. This is often done, though, because most microcontrollers have pull-up resistors built-in, so that you only need the button, the external resistor can then be omitted. Note that you may have to enable the internal pull-up.

See also this answer.

  • \$\begingroup\$ I don't think it's clear how the Push-Down method solves the problem with floating-state from this answer. \$\endgroup\$ Commented Oct 16, 2015 at 20:52

The 10kohm resistor is called a pull-down resistor because, when the "green" node (on connecting the 100ohm and 10kohm resistors) is not connected to +5V by the switch, that node is pulled to ground (assuming low current through that branch, obviously). When the switch is closed, that node gains a potential of +5V.

This is used to control the inputs of logical ICs (AND gates, OR gates, etc), since these circuits will behave erratically if there is no determinate value on their inputs (a 0 or a 1 value). If you leave the input of a logical gate floating, the output cannot be reliably determined, thus it is advisable to always apply a determined input (a 0 or a 1, again) to the gate's input. In this case, P2 would be an input to a specific logical gate, and when the switch is open, it has an input value of 0 (GND); when the switch is closed, it has an input value of 1 (+5V).


current takes the path of least resistance

I'm not sure where does this common misconception come from, but it's indeed wrong as it directly contradicts the Ohm's law. Current takes all possible paths, inversely proportional to their resistance. If you apply 5V to a 10k resistor, 0.5mA will flow through it, regardless of how many alternative paths (low-resistance or otherwise) you provide.

Incidentally, that path through 100 Ohm resistor is not necessarily "least resistance", since the resistor is not connected to ground. Typicall, you would connect that resistor to an MCU input with >10 MOhm impedance, effectively making the 10k resistor the path of least resistance.


The reason the pull-down resistor is required is that the microcontroller is a CMOS device and thus the input pin is ultimately the gate of a MOSFET.

If your pushbutton controlled a bulb or an LED or a relay you would not need a pull-down resistor because an open circuit would be "off". When the button was released the bulb would turn off because no current would flow.

If your device was a true TTL part like the original 7400 series logic chips you would not need the pulldown resistor because those inputs would be bipolar transistors and when the button was released no current would flow through the base-emitter junction and the input would be "off".

In contrast, the input of your microcontroller is a MOSFET gate which acts like a capacitor. When the gate voltage is high enough the input is "on". That happens when you push the button and current flows through the 100R resistor into the microcontroller. The gate charges up (very quickly) like a capacitor and the input becomes "on". Now what happens when you release the button? No more current flows. But what does that mean to the input? If there's no pull-down resistor the charge on the gate has nowhere to go. The voltage will just sit there near 5V and the input will still be "on". The pull-down resistor drains the gate charge so its voltage falls below the "on" level. That's what you want to ensure the digital input is considered "off".

You can experiment with this by hooking two buttons up to your input pin. Tie one to 5V and one to ground. When you push the 5V button the input will turn on. When you release it it will stay on until you push the one that is connected to GND.

  • \$\begingroup\$ In TTL it's indeed the base-emitter junction which will not conduct, but not in the way you might think: the input is the emitter of the input NPN transistor, and the transistor conducts if the input is made low. Floating is the same as high. \$\endgroup\$
    – stevenvh
    Commented Aug 13, 2012 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.