How do diodes work?
Diodes are made of semiconductors, which are essentially the same as photoconductors. These materials normally have electrons filling all of the valence levels and empty conduction levels. The empty conduction levels are at energies well above those of the valence levels so that electrons cannot easily shift from a valence level to a conduction level, a shift that is necessary for the material to conduct electricity. Thus semiconductors are normally insulating. But when the semiconductor is mixed or “doped” with other atoms, it can become conducting. A doping that removes electrons from the valence levels and leaves some of those levels empty produces “p-type” semiconductor. A doping that adds electrons to the conduction levels produces “n-type” semiconductor. Both “n-type” and “p-type” semiconductors can conduct electricity. But when the two materials touch, the form a non-conducting “depletion” region, where all of the conduction electrons in the “n-type” material near the junction have wandered into the “p-type” material to fill the empty valence levels there. This p-n junction or diode can only carry current in one direction. If you add electrons to the “n-type” side of the junction, they will push into the depletion region and can cross over into the “p-type” side. Thus electrons can flow from the “n-type” side to the “p-type” side; current can flow from the “p-type” side to the “n-type” side. But if you add electrons to the “p-type” side, they fill in empty valence levels in that “p-type” material and make the depletion region even larger. The diode cannot conduct current from the “n-type” side to the “p-type” side. Thus the diode is a one-way device for current.