Diodes and transistors are made from semiconductors such as silicon and germanium. Pure semiconductors won’t conduct electric current, but if you dope a semiconductor by adding certain types of impurities, known as dopants, you change the electrical characteristics of the semiconductor, and it will conduct when a voltage is applied to it in just the right way.
The atoms of a pure semiconductor, such as silicon, are held together by strong covalent bonds in a three-dimensional crystalline structure. Each silicon atom shares its 8 valence (outer) electrons with neighboring atoms. By doping a pure semiconductor material, you upset its bonds and free up charge carriers.
Dopants are no dopes; they try to masquerade as one of the crystal’s atoms, attempting to bond with the other atoms, but they are just different enough to stir things up a bit. For instance, an atom of arsenic has one more outer electron than an atom of silicon. When you add a small amount of arsenic to a bunch of silicon atoms, each arsenic atom muscles its way in, bonding with the silicon atoms, but leaving its extra electron drifting around through the crystal. Even though the doped material is electrically neutral, it now contains a bunch of free electrons wandering aimlessly — making it much more conductive. By doping the silicon, you change its electrical properties: Wherever the dopant is added, the silicon becomes more conductive.
Another way to dope semiconductors is to use materials such as boron, in which each atom has one fewer valence electron than does a silicon atom. For every boron atom you add to a silicon crystal, you get what is known as a hole in the crystalline structure where an outer electron should be. Wherever there is a hole in the structure, the bond holding the atoms together is so strong, it will steal an electron from another atom to fill the hole, leaving a hole somewhere else, which then gets filled by another electron, and so forth.
You can think of this process as the hole moving around inside the crystal. (Well, the electrons are moving, but it looks like the position of the hole keeps moving.) Because each hole represents a missing electron, the movement of holes has the same effect as a flow of positive charges.
Impurities that free up electrons (negative charges) to move through a semiconductor are called donor dopants, and the doped semiconductor is known as an N-type semiconductor. Arsenic is a typical donor dopant.
Impurities (such as boron) that free up holes (like positive charges) to move through a semiconductor are called acceptor dopants, and the doped semiconductor is known as a P-type semiconductor. Boron is a typical acceptor dopant.
If you apply a voltage source across either an N-type or a P-type semiconductor, the doped semiconductor acts like a conductor and allows current to flow. But if you combine an N-type and P-type semiconductor, current will flow in only one direction through the pn-junction — and only under certain voltage conditions. By creating different combinations of P-types and N-types, you create different types of diodes and transistors.