An LED stands for light-emitting diode. Before we talk about what an LED is, let's talk about diodes.
Diodes are one of the simplest but most commonly found semiconductor devices. Semiconductors are materials that conduct current, but only partly. The conductivity of a semiconductor is somewhere between an insulator (conducts no electricity) and a conductor (which has almost full conductivity). Common examples of semiconductors are silicon, germanium, or gallium arsenide. Gallium arsenide is the second most common semiconductor, and can be found used in laser diodes and solar cells.
The diode is a two-terminal device; it has an anode also known as the positive terminal, and a cathode which is its negative terminal. Take a look at the STEM components for Raspberry Pi and you will find red, blue, green, yellow and white LEDs. One end or leg of the LED will be longer than the other, this longer end is the anode.
A diode is comprised of a P-type semiconductor and an N-type semiconductor. Between the two is a region that acts as a barrier to electric current.
Add a battery to our circuit as shown, and the voltage from a battery forces charges in the N and P layers towards the junction region between them. Current then begins to flow! Yes, by themselves, the P-type and N-type materials aren't very interesting but if we bring them together, a useful thing happens: current can flow through the resulting semiconductor, but only in one direction.
This brings us to our next point about diodes: they are unidirectional so they only allow current to flow through them in one direction, known as the forward direction. This happens when the anode of the diode has a higher positive potential than the cathode.
If we reversed the polarity (by for example, flipping the battery in the circuit as shown in the diagram) then current flow is blocked. The diode is now reverse biased. Here, the N and P layers are attracted away from the central junction, which becomes a depletion region, unable to pass significant current.
In other words, a diode may be thought of as like a switch: it is “closed” when forward-biased and “open” when reverse-biased.
Please note that even though we mentioned no current flowing when reverse-biased, this is only theoretically the case. We've talked about tolerance in resistors, likewise a diode is not 100% efficient.
When it is forward biased and current is flowing, it imposes a voltage drop of 0.7V for a sillicon-based diode. On the other hand, when reversed biased, a small amount of current manages to get through. This is known as leakage and is almost always less than 1 mA.
While there are many different types of diodes, we will focus on the light-emitting diode for now. There are LEDs from single-coloured, multi-colour, low-power, and high-powered ones. The LEDs from our STEM components for Raspberry Pi are single-coloured LEDs that can be used for indication or illumination, as visual feedback from our circuit.
While it is simple to light an LED, it needs to be done properly in order to protect the components in your circuit. For example, when connecting it to the Raspberry Pi, this needs to be done with a resistor to prevent it from drawing too much current and burning itself out.
Different LEDs will be rated at a certain amount of current. Your Raspberry Pi supplies another amount of current and may even try to supply far more than it should. Thus, your resistor choice should be appropriate for these values. How to choose a resistor for your circuit? You can calculate this with Ohm's Law.