|
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. We're interested in the output of the inverter (which is inside the Arduino, and goes to other logic in the Arduino). Since it's an inverter, note that it will be the opposite of whatever is read on the input pin.
Start with both switches off. When you start the simulation, the circuit on the left will output... some random voltage that is neither 0V nor 5V. 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 5V, thanks to the 10kΩ resistor which (by Ohm's law) has no voltage drop across it. So the inverter correctly outputs 0V.
Now, turn both switches on. Bingo! Everything works in both circuits, which both dutifully output 5V (the input is 0V). 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 0V, 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.
|