Flashing, Dimming, and Oscillating
For many electronic appliances and art pieces, turning the device on and off simply means plugging it in or unplugging it from the wall.
Other devices have simple switches, which are not a lot more complicated than plugging into a wall. A switch simply connects two wires together electrically. You can do this by hand for low voltage things like LEDs. Just touch two wires together, and it lights up. You have made a simple switch.
We also know that the brightness of the LED is determined by how much current is flowing through it. And we know we can limit the current using a resistor. This means we know how to dim the lights. Just increase the resistance.
We can replace our current limiting resistor with a variable resistor. The technical name for a variable resistor is a potentiometer. Volume controls on radios and televisions used to be simple potentiometers. These days they are more often buttons on a remote control that tells a computer how much to amplify the sound.
Since potentiometers can be set to zero (no resistance), we will want to still have our fixed resistor to ensure that we don't burn out the LED with too much current. The potentiometer can then be selected to have, say, 2000 or 5000 ohms of resistance when it is at its highest setting (equivalent to the lowest volume on a volume control). The LED will appear to be so dim that it looks like it is off, until we turn up the current by rotating the knob on the potentiometer.
Because potentiometer is too many syllables, we often refer to one simply as a "pot".
A potentiometer has three terminals we can solder wires to. The outside terminals are connected to each end of a resistor, just like the ones we used in our LED project. The center terminal connects to a wiper. The wiper is a piece of metal that moves from one end of the resistor to the other, making a connection to the resistor material. The schematic symbol for the potentiometer shows the wiper as an arrow pointing to the middle of the resistor.
If we ignore the wiper, and simply connect the outside terminals of the pot in our circuit, we just have an expensive resistor. But if we connect the wiper and one of the outside terminals, we have a variable resistor (also known as a rheostat). When we connect the outside terminals to the two ends of a battery, we have a voltage divider (remember the voltage divider we discussed earlier?). The wiper then lets us select any voltage from the highest the battery can deliver, to zero, with a convenient twist of the knob.
Sometimes we want something to turn on and off by itself, without someone's hand being involved. We see blinking lights on all kinds of things, as they draw our attention, which is their purpose. To make a light blink, we need something that changes over time. That something is an electronic part called a capacitor.
A capacitor is a very simple thing. It is two conducting surfaces, separated by an insulator. When connected to a voltage source such as a battery, one surface in the capacitor get electrons pushed onto it, and the other surface gets electrons removed from it. This results in storing electrical energy in the capacitor, very much like charging a battery. That is because when we put an LED in place of the battery, the electrons crowded onto one surface race through the LED to the surface that is deficient in electrons. This lights the LED, until the surfaces are balanced again.
It takes time to charge a capacitor, and it takes time to discharge one. We can change this timing by limiting how fast the electrons can get into and out of the capacitor. We do this with a current limiting resistor.
The combination of a capacitor and a resistor gives us a way of telling time. If we allow the capacitor to charge through the resistor, the voltage between the two surfaces in the capacitor rises until it gets close to the voltage of the battery. It continues to gradually get closer and closer to the battery voltage, but the rate of voltage rise gets slower and slower, exponentially.
In the diagram above, an oscilloscope is connected at either end of the capacitor (that's the new schematic symbol, just below the resistor). A battery (the new schematic symbol on the left) provides (in this case) 3 volts. A switch (the new schematic symbol at the top) can connect the resistor and capacitor to either the top of the battery, giving it power, or the bottom of the battery, shorting it out.
You can click on the "charge" and "discharge" buttons to watch the capacitor charge or discharge. You can also change the values of the resistor and capacitor.
We can set up a circuit made of transistors that charges a capacitor through a resistor and monitors the voltage level. When the voltage rises to a particular level, the circuit will switch to discharging the capacitor through a resistor until the voltage reaches a second, lower level. At this point it starts charging again, and the cycle repeats. We now have a circuit that can tick at any rate we desire, simply by making the capacitor bigger or smaller, or making the resistor bigger or smaller, or some combination. This circuit is called a timer. In the diagram, clicking on the "auto" button simulates a timer.
Timers are so useful in electronics that companies make integrated circuit chips that include all of the transistors and other components, all connected for us already, in a little chip. All that remains is for us to add the capacitor and resistors (one to charge through, and one to discharge through). This lets us set the timing however we desire.