Testing | Colours | RGB | Vision | Size/shape | Resistor | LEDs in series | LED data | Flashing | Displays
LEDs emit light when an electric current passes through them.
The electrical behaviour of an LED is quite different from a lamp and it must be protected from passing excessive current, usually this is achieved by connecting a resistor in series with the LED. Never connect an LED directly to a battery or power supply.
LEDs must be connected the correct way round, the diagram may be labelled a or + for anode and k or - for cathode (yes, it really is k, not c, for cathode). The cathode is the short lead and there may be a slight flat on the body of round LEDs. If you can see inside the LED the cathode is the larger electrode but this is not an official identification method.
LEDs can be damaged by heat when soldering but the risk is small unless you are very slow. No special precautions are needed for soldering most LEDs.
Rapid Electronics: full range of LEDs
Rapid Electronics, standard 5mm LEDs: red | yellow | green | blue
Never connect an LED directly to a battery or power supply because the LED is likely to be destroyed by excessive current passing through it.
LEDs must have a resistor in series to limit the current to a safe value, for testing purposes a 1kΩ resistor is suitable for most LEDs if your supply voltage is 12V or less. Remember to connect the LED the correct way round.
Please see below for an explanation of how to work out a suitable resistor value for an LED.
The colour of an LED is determined by its semiconductor material, not by the colouring of the 'package' (the plastic body). LEDs of all colours are available in uncoloured packages which may be diffused (milky) or clear (often described as 'water clear'). The coloured packages are also available as diffused (the standard type) or transparent.
Blue and white LEDs may be more expensive than the other colours.
A bi-colour LED has two LEDs wired in 'inverse parallel' (one forwards, one backwards) combined in one package with two leads. Only one of the LEDs can be lit at one time and they are less useful than the tri-colour and RGB LEDs described below.
The most popular type of tri-colour LED has a red and a green LED combined in one package with three leads. They are called tri-colour because mixed red and green light appears to be yellow and this is produced when both the red and green LEDs are on.
The diagram shows the construction of a tri-colour LED. Note the different lengths of the three leads. The centre lead (k) is the common cathode for both LEDs, the outer leads (a1 and a2) are the anodes to the LEDs allowing each one to be lit separately, or both together to give the third colour. Note that each internal LED must have a resistor in series to limit the current.
Rapid Electronics: red/green LED
RGB LEDs contain Red, Green and Blue LEDs in one package. Each of these three internal LEDs has its own lead and each must have its own resistor in series to limit the current.
The cathodes (or anodes) of the internal LEDs are connected together to a common lead - look for 'common cathode' (CC) or 'common anode' (CA) in the product description. Make sure you buy the right type, CC or CA, they are not interchangeable.
Rapid Electronics: 5mm RGB LED (common cathode)
Rapid Electronics: 5mm RGB LED (common anode)
The diagram shows example connections for the leads of a 5mm diameter RGB LED. For this style the longest lead is always the common cathode (CC) or common anode (CA) as appropriate.
The 3 other leads (labelled R, G and B on the diagram) connect to the red, green and blue LEDs inside the package but not necessarily in the order shown, you may need to connect each one in turn to identify its colour - remember to include a suitable resistor in series, 1kΩ is suitable for up to 12V, see Testing an LED above.
Red, Green and Blue are the primary colours of light (see colour vision below). Each internal LED can be switched on and off separately allowing a range of colours to be produced:
A much wider range of colours can be produced by varying the brightness of each internal LED, for example by using Pulse Width Modulation (PWM).
The full range of colours we see can be produced with just three primary colours of light:
These three colours are sufficient because human eyes have only three types of colour detecting cells, each type is most sensitive to red, green or blue light.
Other colours are seen when two or three types of these cells detect light, for example:
Yellow light is detected equally by the red and green sensitive cells, so the same colour will be seen by an equal mixture of red and green light.
Orange light is detected strongly by red cells and weakly by green cells, this is the same as a mixture of bright red and less bright green light.
Pink light is detected most strongly by red cells but also by green and blue cells, this is the same as a mixture of bright red, moderate green and moderate blue light.
If you look closely at an old television or computer screen you may be able to see tiny dots of red, green and blue. The dots are hard to see on modern screens (even with the aid of a hand lens) because they are made very small to give a high resolution picture.
The primary colours for paints and printing inks are different from those for light because they work by absorbing one of the primary colours of light and reflecting the remaining colours.
The primary colours for painting and printing are:
Other colours can be produced by mixing these primary paint and ink colours. For example mixing Cyan and Magenta ink gives Blue (because red light has been absorbed by the cyan ink and green absorbed by the magenta ink, leaving only blue light to be reflected).
Note that Black ink is also used in printing to reduce costs, it also gives a better black than mixing cyan, magenta and yellow because primary ink colours are not perfect.
But I was taught that the primary paint colours are red, yellow and blue...
That's a common misunderstanding, usually from the early years at school.
You can see the problem if you mix yellow and blue paint: the result is a dull grey-green. For a much better green mix yellow and cyan!
The visible spectrum ranges from red (long wavelength, about 700 nm) through yellow, green, cyan and blue to violet (short wavelength about 400 nm). As well as all the colours in the spectrum, the human eye can also see colours which are made by mixing light from different parts of the spectrum: for example magenta which is a mixture of red and blue.
LEDs are available in a wide variety of sizes and shapes. The 'standard' LED has a round cross-section of 5mm diameter and this is the best type for general use, but 3mm round LEDs are also popular.
Round cross-section LEDs are frequently used and they are very easy to install on boxes by drilling a hole of the LED diameter, adding a spot of glue will help to hold the LED if necessary. LED clips (illustrated) are also available to secure LEDs in holes. Other cross-section shapes include square, rectangular and triangular.
Photograph © Rapid Electronics
As well as a variety of colours, sizes and shapes, LEDs also vary in their viewing angle. This tells you how much the beam of light spreads out. Standard LEDs have a viewing angle of 60° but others have a narrow beam of 30° or less.
Rapid Electronics stock a particularly wide selection of LEDs and their website is a good guide to the extensive range available including the latest high power LEDs.
An LED must have a resistor connected in series to limit the current through the LED, otherwise it will burn out almost instantly.
The resistor value, R is given by:
R = (VS - VL) / I |
R = resistor value in ohms (Ω).
VS = supply voltage.
VL = LED voltage (2V, or 4V for blue and white).
I = LED current in amps (A)
The LED current must be less than the maximum permitted for your LED. For standard 5mm diameter LEDs the maximum current is usually 20mA so 15mA (or less) is a suitable value for most circuits. The current must be in amps (A) for the calculation, to convert from mA to A divide the current in mA by 1000.
Choose a standard resistor value which is a little greater than your calculated value so the current will be a little less than you chose. You may wish to choose a greater resistor value to reduce the current (to increase battery life for example) but this will make the LED less bright.
Supply voltage, VS = 9V
Red LED, VL = 2V
Current, I = 15mA = 0.015A
Calculate: R = (9V - 2V) / 0.015A = 467Ω
Choose: 470Ω resistor.
The LED voltage VL is determined by the colour of the LED. Red LEDs have the lowest voltage, yellow and green are a little higher. Blue and white LEDs have the highest voltages.
For most purposes the exact value is not critical and you can use 2V for red, yellow and green, or 4V for blue and white LEDs.
Ohm's law says that the resistance of the resistor, R = V/I, where:
V = voltage across resistor (VS - VL in this case)
I = the current through the resistor
So R = (VS - VL) / I
For more information on the calculations please see the Ohm's Law page.
If you wish to have several LEDs on at the same time it may be possible to connect them in series. This prolongs battery life by lighting several LEDs with the same current as just one LED.
All the LEDs connected in series pass the same current so it is best if they are all the same type. The power supply must have sufficient voltage to provide about 2V for each LED (4V for blue and white) plus at least another 2V for the resistor. To work out a value for the resistor you must add up all the LED voltages and use this for VL.
A red, a yellow and a green LED in series need a supply voltage of at least
3 × 2V + 2V = 8V, so a 9V battery would be ideal.
VL = 2V + 2V + 2V = 6V (the three LED voltages added up).
If the supply voltage VS is 9V and the current I must be 15mA = 0.015A,
Resistor R = (VS - VL) / I = (9 - 6) / 0.015 = 3 / 0.015
= 200Ω,
so choose R = 220Ω
(the nearest standard value which is greater).
Connecting several LEDs in parallel with just one resistor shared between them is generally a bad idea.
If the LEDs require slightly different voltages only the lowest voltage LED will light and it may be destroyed by the larger current flowing through it. Although identical LEDs can be successfully connected in parallel with one resistor this rarely offers any useful benefit because resistors are very cheap and the current used is the same as connecting the LEDs individually.
If LEDs are in parallel each one should have its own resistor.
Suppliers' websites and catalogues usually provide tables of technical data for components such as LEDs. These tables contain a good deal of useful information in a compact form but they can be difficult to understand if you are not familiar with the abbreviations used. These are the important properties for LEDs:
The following two properties can be ignored for most circuits:
Flashing LEDs look like ordinary LEDs but they contain an IC (integrated circuit) as well as the LED itself. The IC flashes the LED at a low frequency, for example 3Hz (3 flashes per second). Flashing LEDs are designed to be connected directly to a particular supply voltage such as 5V or 12V without a series resistor. Check with the supplier to find the safe supply voltage range for a particular flashing LED. The flash frequency is fixed so their use is limited and you may prefer to build your own circuit to flash an ordinary LED, for example the Flashing LED project which uses a 555 astable circuit.
Rapid Electronics: Flashing LEDs
For breadboard projects using a 555 astable circuit to make LEDs flash see Breadboard Workshop 1.
LED displays are packages of many LEDs arranged in a pattern, the most familiar pattern being the 7-segment displays for showing numbers (digits 0-9). The pictures below illustrate some of the popular designs.
Bargraph, 7-segment, Starburst and Dot-matrix LED displays
Photographs © Rapid Electronics
Rapid Electronics: LED displays
There are many types of LED display and a supplier's catalogue or website should be consulted for the pin connections. The diagram on the right shows an example from Rapid Electronics. Like many 7-segment displays, this example is available in two versions: Common Anode (SA) with all the LED anodes connected together and Common Cathode (SC) with all the cathodes connected together. Letters a-g refer to the 7 segments, A/C is the common anode or cathode as appropriate (on 2 pins). Note that some pins are not present (NP) but their position is still numbered.
Also see: Display Drivers.
Pin connections diagram
© Rapid Electronics
Rapid Electronics have kindly allowed me to use their images on this website and I am very grateful for their support. They stock a wide range of LEDs, other components and tools for electronics and I am happy to recommend them as a supplier.
As an Amazon Associate, I earn from qualifying purchases. Any book you purchase through the Amazon links helps to keep this website available for everyone to use free of charge.
Next page: Relays