By themselves, P-type (positively charged) and N-type (negatively charged) semiconductors are just conductors. But if you put them together on an electronic circuit, you create a p-n junction and an interesting and very useful thing happens: Current can flow through the p-n junction, but only in one direction.

If you put positive voltage on the p side of the junction and negative voltage on the n side, current flows through the junction. But if you reverse the voltage, putting negative voltage on the p side and positive voltage on the n side, current doesn't flow.

Picture a turnstile gate such as the gates you must go through to get into a baseball stadium or a subway station: You can walk through the gate in one direction but not the other. That's essentially what a p-n junction does. It allows current to flow one way but not the other.

To understand why p-n junctions allow current to flow in only one direction, you must first understand what happens right at the boundary between the p-type material and the n-type material. Because opposite charges attract, the extra electrons on the n-type side of the junction are attracted to the holes on the p-type side. So they start to drift across to the other side.

When an electron leaves the n-type side to fill a hole in the p-type side, a hole is left in the n-type side where the electron was. Thus, it's as if the electron and the hole trade places. The boundary of a p-n junction ends up being populated by defectors: Electrons and holes have crossed the boundary and are now on the wrong side of the junction.

This region that is occupied by electrons and holes that have crossed over is called the depletion zone. Because one side of the depletion zone has electrons (negative charges) and the other side has holes (positive charges), a voltage exists between the two edges of the depletion zone.

This voltage has an interesting effect on the defectors: It beckons them to turn around and come home. In other words, the holes that have jumped to the negative side of the junction attract the electrons that have jumped to the positive side.

Imagine what it's like to be an electron that has jumped over the boundary and into the p-type side of the junction. Being negatively charged, you're attracted to move further into the p side by the positively charged holes you see ahead of you.

But you're also attracted by the positively charged holes that now lie behind you — the very same hole you traded places with now exerts a pull on you that discourages you from going any further.

Unable to make up your mind, you decide to just stay put. That's exactly what happens to the electrons and holes that have crossed over to the other side. The depletion zone becomes stable — a state that's called equilibrium.

Now consider what happens when the equilibrium is disturbed by a voltage placed across the p-n junction. The effect depends on which direction the voltage is applied, as follows:

• If you apply positive voltage to the p-type side and negative voltage to the n-type side, the depletion zone is pushed from both sides toward the center, making it smaller. Electrons in to the n-type side of the junction are pushed by the voltage toward the depletion zone and eventually collapse it completely. When that happens, the p-n junction becomes a conductor, and current flows.

• When voltage is applied in the reverse direction, the depletion zone is pulled from both sides of the junction, and thus it expands. The larger it gets, the more of an insulator the p-n junction becomes. Thus, when voltage is applied in the reverse direction, current doesn't flow through the junction.