Understanding pull-up resistors

What's in the circuit

In the embedded EveryCircuit below, the circuit on the left shows an input switch circuit without a pull-up resistor. The circuit on the right shows it with a pull-up resistor.

The input switch circuit comprises the resistor and the switch. The two transistors arranged in a CMOS inverter aren't part of the circuit: they're inside the Arduino.

What to look at

We're interested in the output of the inverter (which is inside the Arduino, and goes to other logic in the Arduino). There is a voltage trace on each of these in the simulation. The blue trace is the one on the left; the green trace is the one on the right. There are dots on the circuit where these probe points are.

In the embedded frame below, the traces are in the top-left corner. Click on them to expand them into a full graph. Then move the circuit down a little so you can see all of it.

Since it's an inverter, note that the output will be the opposite of whatever is read on the input pin.

Link.

Interacting with the circuit

Start with both switches off. When you start the simulation, the circuit on the left will output… some random voltage that is neither 0 V nor 5 V. What? How? Well, the input pin isn't connected to anything (“floating”), so its voltage is basically random, and this causes the transistor circuit to do funny things. Floating input pins are bad.

The circuit on the right, however, will have its input pin at 5 V, thanks to the 10kΩ resistor which (by Ohm's law) has no voltage drop across it. So the inverter correctly outputs 0 V.

Now, turn both switches on. Bingo! Everything works in both circuits, which both dutifully output 5 V (the input is 0 V). This is expected: when the switch is closed, the input pin is connected to ground in both circuits, so everything is find in both worlds.

Finally, turn both switches off again. The circuit on the right will go back to 0 V, just as it was before. But the circuit on the left? It's staying where it was! So releasing the switch didn't do anything. Why? Well, now the input pin is floating again… but this time, it “remembers” what voltage was there before. (This is because the gates of transistors function as capacitors. We haven't learnt about these yet, and we'll cover them later in the course.) But although the voltage isn't random any more, it's both useless (the switch didn't do anything!) and very unreliable. Floating input pins are bad.

Explore further

If you want to try something else based on this circuit, click on “edit in everycircuit.com” in the frame above and you can save a copy of your own to play with.