I'll explain some simple diode functions using Snap Circuits.
Direct current (DC)
In a DC (direct current) circuit where the electricity flows in one direction, we can think of a battery as a storage tank like the water tower in your neighborhood. If nobody turned on their faucet, the water in the tower would just sit there. Forever. Physicists like to think of this as "potential energy." Like a boulder at the top of a hill, it will just sit there, forever, until someone pushes it over the hill or an earthquake shakes it from the top of the hill or erosion undermines it starting it to roll down the hill. When the boulder is rolling down the hill, physicists like to think of this as kinetic energy. So, the water will just sit in the top of the water tower until you turn on the faucet to your water hose. The water will then flow from the top of the water tower through your water hose and then on to the ground. You can then think of the flow of water as kinetic energy and this kinetic energy can be used to do useful work.
When no circuit is connected to your battery, it is like a storage tank, or potential energy. When a circuit is connected to your battery, you can think of electrons flowing through the circuit as kinetic energy that can be used to do useful work such as light up an incandescent light bulb or light emitting diode (LED).
You can thank Ben Franklin for a bit of confusion that often arises regarding electron flow and current flow. Franklin studied electricity before the discovery of the electron and simply had to guess—and he guessed wrong—so, current flow is backwards. Electrons have negative charges and flow in the opposite direction of current.
Confused? No worries. Just stick with “current flow” (also called “conventional current” or “conventional electricity”) and think of “current” flowing from the positive ("+") terminal on your battery to the negative ("-") terminal, or ground, like the water flowing from the top of the water tower, through your garden hose, and onto the ground.
Alternating current (AC)
Direct current by definition flows in one direction. Alternating Current (AC), on the other hand, periodically changes direction, or reverses polarity. To use a diving analogy, imagine a scuba diver. Since scuba divers carry their air with them they can still breathe whether their heads are above water or underwater. You can imagine a scuba diver surfacing and diving repeatedly and the path he or she traces forms a sine wave.
The sine wave is what Alternating Current looks like. At the crest, or top of the wave you might measure +5 volts and at the trough, or bottom of the wave you might measure -5 volts. At the line through the middle you would measure 0 volts.
It is indeed possible for a portion of a circuit that is normally DC to periodically change direction, or reverse polarity like an AC circuit. Examples can include some 555 timer circuits and circuits that drive DC motors. Some electronic components can be sensitive to reverse polarity and can be damaged by sending electricity through them the wrong way. To protect these components, you can install a diode in the circuit.
According to Wikipedia, “The most common function of a diode is to allow an electric current to pass in one direction (called the diode's forward direction), while blocking current in the opposite direction (the reverse direction). Thus, the diode can be viewed as an electronic version of a check valve." (Source)
What is a check valve? You can think of it like a ping pong ball cage snorkel. When the ping pong ball cage is above the surface of the water, the ping pong ball is at the bottom of the cage and you can breathe through the snorkel. As the cage moves below the surface of the water, the ping pong ball floats up until it blocks the opening of the snorkel blocking any water from getting into the snorkel.
We can use the diode to convert Alternating Current to Direct Current. Now...Read more »