Project: Flashing LEDs with an integrated circuit
We now know how to control electrical current with resistors and how to store electrical charge in capacitors. We know how to combine those two parts to create a time delay. We are ready to use that knowledge in our first project that uses an integrated circuit chip.
The 555 timer chip is a tiny little thing that has several transistors and resistors all connected together inside to make a building block for electronics projects that works like an electrical Lego® block. We will combine it with some resistors, a capacitor, and an LED to make the LED turn on and off at any rate we choose.
The 555 is a versatile building block, and is so handy that over a billion of them are manufactured and sold every year. What it does in this project is fairly simple -- it charges an external capacitor through an external resistor until the capacitor reaches 2/3rds of the power supply voltage. Then it flips an internal switch and starts discharging the capacitor though another external resistor, until the capacitor reaches 1/3rd of the power supply voltage. Then the switch flips again, and the process repeats, over and over again. This action makes our circuit an oscillator.
The little chip can also be configured to be a timer. In that configuration is simply turns something on or off for a specific time, and then returns to its previous state.
Later, we will use the chip to change the brightness of an LED, and to control motors. But for now, we are going to control how our LED flashes on and off.
Let's look for a moment at just the left-hand side of the schematic shown above. Between the plus and the minus of the power supply, we have two resistors and a capacitor. If the 555 timer chip is not there, the capacitor will charge through the two resistors until it approaches nine volts.
We know from our earlier discussion of capacitors that this takes some time. That is the key to how this circuit works.
How it works
When we first connect the power supply, the LED turns on. This is because pin 3 of the 555 timer starts out at zero volts (it is connected to the negative side of the power supply by an internal switch). This allows current to flow through the LED and its current limiting resistor, R3.
As the capacitor charges, the voltage at pin 2 gradually rises.
Pin 2 of the 555 timer is called the trigger pin. If the voltage at this pin reaches 6 volts (2/3rds of the power supply voltage), the chip will use some internal switches to connect pin 3 to the positive power supply (so the we see 9 volts on pin 3), and connect pin 7 to the negative power supply, so we see 0 volts on pin 7.
When pin 3 is at 9 volts, the LED turns off, because both sides of the LED have the same voltage, and no current flows through anything if both sides are at the same voltage.
Pin 7 of the 555 timer is called the discharge pin. When it goes to zero volts, all the power goes through resistor R1, and almost none of it gets to any of the rest of the circuit. The capacitor not only stops charging, but it starts discharging through R2 into pin 7. The voltage at pin 2 now starts to slowly drop from 6 volts down to 3 volts.
Pin 6 of the 555 timer is called the threshold pin. In this circuit we have connected it to the same place as pin 2, so it also monitors the voltage on the capacitor.
When the voltage at pin 6 reaches 3 volts (1/3rd of the power supply voltage), the internal switches are reset. Pin 7 is no longer connected to the negative power supply, and pin 3 is. The LED turns back on, and the capacitor starts charging again.
So the whole circuit now oscillates, going from one state to the other and back again. The voltage at the capacitor goes from 6 volts to 3 volts and back again, and the LED turns on, then off, and then back on, over and over.
You may want to take some time to study the description above until it makes complete sense to you before we start talking about the rest of the pins on the 555 timer.
The other pins
Pin 1 is connected to the negative side of the power supply. This side is called ground in electronics, and in many circuits (like the power to your house) it is actually connected to a big metal spike driven into the dirt on which the house is built. Which is why it is called ground. The earth is so big that it can absorb as many electrons as we can give it, and we can't detect any change in its voltage. It can also deliver as many electrons as our circuit can suck out of it, and still never seem to change voltage. If your house wiring was not electrically connected to the ground, you might get a shock when you touched a lamp or appliance, as the house current would use your body as a conductor to send current into the earth.
Our circuit is probably battery operated, and doesn't actually need to be connected to the earth, but the negative side of the battery is still called "ground", and we will use that term a lot in the remainder of this book.
Pin 8 of the 555 timer is connected to the positive side of the power supply. This is how the chip gets the power it needs to operate.
Pins 4 and 5 are used to change how the chip operates. In our circuit, pin 4 (the reset pin) is not used, and we connect it to the positive power supply to ensure that it does not change and suddenly reset the timer. Pin 5 is the control pin, and is also not used in our circuit. We connect it to ground through a small capacitor, to ensure that it also stays stable. The small capacitor absorbs any sudden changes in the power supply (we call these sudden changes noise) that might result from other circuits turning on and off. Since there are no other circuits in this simple example, we could actually eliminate the capacitor, and leave pin 5 unconnected. But it is a good practice to connect it as we have, just in case.