In our electrical circuits, we will need to consider variables of voltage (V) and current (I). It might be helpful to think of a water hose as an analogous system. Voltage is like water pressure and current is like the velocity of the water passing through the hose.
The following Introduction to Electronics
should be helpful for those without any background in electronics.
All of our circuits will include one or more resistors, which in our water-hose analogy are like sponges inserted inside the hose to slow the water flow.
Ohm's Law relates the voltage (V) across a resistor (R) and the current (I) flowing through it as V = I R.
In general, our voltage source will be 5 Volts.
Resistances are specified in Ohms (). Physical resistors are color-coded
to indicate their resistance values.
We'll want to limit the current in our circuits to minimize power consumption. For example, in a typical switch circuit we'll add a 10 K ohm resistor so that the current when the switch is closed is I = V / R or 0.0005 amps (0.5 milliamps).
Figure 1:
A basic switch circuit.
For the circuit of Fig. 1, the voltage measured at the digital pin with the switch open is zero because there is no current in the circuit and thus no voltage drop across the resistor. When the switch is closed, there is a direct connection to the +5V source and the digital input pin will register a “high” value.
Because the voltage level just after the switch will only have two possible values, we can use a digital input pin to read those voltage levels.