How transistors work: Illustrated
After fruitless searches in electronics books, electrical engineering textbooks, even physics, trying to find a way to understand transistors (not just where to put one in a circuit), I stumbled upon the answer when I wasn’t looking for it.
Chemistry. The answer is in chemistry. Specifically, it is in The Joy of Chemistry by Cathy Cobb and Monty L. Fetterolf.
I draw pictures when I want to understand something, so here you go.
One way to imagine an atom looks like a solar system, with a positive nucleus at the center, orbited by negatively charged electrons in discrete shells, with rules about how many electrons can go in each shell. The periodic table is laid out according to this idea. As you march to the right, each atom has one more electron in its outermost shell, until you hit a big ol’ carriage return and start filling the next shell.
The outermost electron shell of an atom is called its valence shell, and how full it is determines the chemical properties of the atom.
An atom with a filled valence shell is stable and inert. The noble gases, the rightmost column of the periodic table, sit where they are and behave the way they do because their valence shells are filled. Atoms without a filled outer shell will swap and share electrons with other atoms to get to that state.
When atoms swap electrons and then stick to each other like oppositely charged magnets, that’s an ionic bond. When they share electrons, it’s called a covalent bond (as in, co-sharing valence electrons).
Copper is interesting.
For one thing, it’s a metal, so that means it’s shiny, bendy, and ready to make metallic bonds. (That’s the third kind of bond.) Metallic bonds are like covalent bonds, only a whole lot more so.
When many copper atoms get together, they share electrons so readily the electrons form a conduction band encompassing all the atoms. This makes copper a great conductor of electricity, since electricity is the flow of charged particles (such as electrons). So we make the wires in our houses out of copper. (Or aluminum, if your house was built in the 70s. Sigh.)
We make the transistors in our computers, on the other hand, out of silicon.
Silicon has four valence electrons, but its shell would be filled if it had eight. This lets silicon atoms bond with other silicon atoms in a complex lattice, fancier than what I could draw here in 2D.
Crystals don’t conduct. But if we swapped out one of those silicon atoms with something else, something that had an extra electron, or maybe something that had a spare spot to accept an electron, then we’d have something that could conduct. Some of the time, anyway. It would be a… _semi_conductor.
Adding impurities to silicon to change its electrical properties is called doping. Good choices for doping silicon are the atoms sitting on either side of it on the periodic table.
Aluminum is one spot to the left of silicon, because it has one fewer electron. Phosphorus is one spot to the right, because it has one more electron. Having extra electrons that are easy to knock free, plus “holes” where spare electrons can go, makes a material able to move those electrons along. In other words, conduct electricity.
Silicon doped with phosphorus makes an n-type semiconductor. Silicon doped with aluminum makes a p-type semiconductor. Side-by-side, they make a component called a diode.
Diodes are useful when you want to ensure current can flow through your circuit in only one direction. One practical application is circuits with electromagnets. Electromagnets when they’re shut off can kick current back and damage your microcontroller, so you put a diode between the two, letting the microcontroller send current to the electromagnet but protecting it from this flyback.
If a diode is an n plus a p, what do you get with n, p, and another n (or p, n, and p)?
Transistors are like two diodes stuck back-to-back. Since diodes let current flow in only one direction, this is like attaching a valve that lets liquid flow only from right to left to a valve that allows flow only from left to right; i.e., no flow at all. That sounds kind of useless.
Applying a current to the p-type semiconductor in the middle segment knocks some electrons free, switching it to behave like an n-type semiconductor. Now the transistor is N-N-N instead of N-P-N, and current can flow through it.
In this way, the transistor acts like an on/off switch. A small current can flip the switch, either allowing or blocking a big current. This is exactly what you need when you want your arduino microcontroller, which can only pump 5 volts out of its output pins, to decide when to switch on something with a bigger power draw, like a motor or a fountain pump.
Combining transistors into a computer is left as an exercise for the reader.
Check out The Joy of Chemistry. It makes not only transistors but a lot of other things make sense (like, how does your toilet actually flush?). It has illustrative experiments and then, because the authors know their audience are grown-ups, descriptions of what would have happened if you’d done the experiment. And I love that this book knows that science is fun all on its own and doesn’t need cutesy distractions or wisecracks to make the book “engaging.”
Now, can anybody tell me what it means—means-means, not just the effects you observe—when a microcontroller pin is “floating”?
UPDATE: Andy Philips explains “float” in the comments.