Exercise: Switch with pullup¶
Sense a mechanical action as a varying voltage.
A switch is a special case of a resistor with two states: it has either near-zero resistance when closed or near-infinite resistance when open. A resistor in series with a switch is a very common voltage divider construction in which the pull-up resistor can supply a small current through the switch. If the switch is closed, its resistance is near zero, so the output is connected directly to ground. If the switch is open, the current through the resistor is zero, so there is no voltage drop and the output is pulled up to the supply voltage.
In this example, R1 is the 5.6K pull-up resistor. The exact value of 5.6K is not critical; for our purposes values from 1K to 100K will all work fine to supply a logic signal to an Arduino.
The switch is drawn as a single-pole single-throw switch (SPST) which can only open or close the connection between two pins. It is drawn as a normally-open switch which makes the connection when operated.
Steps and observations¶
Set up the resistor and switch on a breadboard; a suggested layout is shown below.
Measure the exact resistor value.
Measure the supply voltage.
Measure the voltage across the switch in both states.
Measure the current through the resistor in both states. Compare to predictions.
Create a simple switch from wire and use it to sense some kind of mechanical activity. (Keep this simple, this should only take a minute or two.)