browser BACK buttonRobert's Trains home page

How to use LEDs, calculate resistor values and more

This page explains how to work out the resistor value required for a simple LED circuit.

This page is aimed at people with limited electronics skills. Please contact me for further information or if you need help.

What is an LED?:

An LED is an electronic component or semiconductor to be more precise. This means that it is neither a conductor (something that conducts electricity) or insulator (something that does not conduct electricity) - it is something in between. LED is an acronym for Light Emitting Diode. Simply put, a diode is a device that only allows current flow in one direction and blocks it flowing in the other direction. The LED is a diode that emits light when current flows through it in the correct direction. This also means that the LED is a polarized device - it has a positive and negative side (also known as anode and cathode respectively). If it is not the right way around in the circuit to be used, current will not flow and no light will be emitted. LEDs also don't like to be installed the wrong way around. One a certain voltage level is reached, the LED can self-destruct if installed back-to-front.

Each leg of an LED is identified by its length. The longer leg is known as the anode or positive side The shorter leg is known as the cathode, or negative side. Normally, looking from the top, there is a "flat" side of the LED - this also signifies the cathode.

To use an LED:

To use an LED, you should find out the specifications about their performance. This will show things like viewing angle, voltage, current required, possibly the light wavelength emitted and a few other parameters. The main ones are voltage and current. As a general rule of thumb, the voltage could be considered as 2V, and current considered as 20mA (milli-amps, or 0.02A). If you don't know the particular specifications of the LED you are using (it could be 1.8V or 2.2V or 30mA for example), use the above rule-of-thumb figures.

What you need:

For a basic circuit of a single LED and power source, a resistor (a semiconductor that has a known value of resistance) is required to limit the current and reduce the voltage so that the LED can operate correctly. Too much voltage or too much current can either destroy the LED in a split second, or greatly reduce its life span. I prefer to slightly under-rate the LED to prolong its life span. The power source to the LED should also be regulated. That means that the voltage output (or in some cases the current output) is controlled and does not fluctuate under varying load conditions. If the power source is not regulated, the small fluctuations and glitches in power can shorten the life of the LEDs in extreme cases.

To get the LED to work:

A simple circuit to operate the LED from a known power source, requires only a resistor in series with the LED. Consider that we have a 12V DC power source, a common variety LED (2V, 20mA). All we need to do is calculate the resistor value. As the components will be wired in series, the current flow through all components is equal. So we have a known LED voltage drop (2V) and a desired current flow of 20mA (or slightly less), we can now calculate the resistor value with Ohm's Law. That is Voltage (V) = current (I) x resistance (R). As we are looking for resistance, the formula will be resistance (R) = voltage (V) divided by current (I). Since we have 12V as the supply voltage and the LED will "drop" 2V across it, that leaves 10V "drop" across the resistor and a current of 20mA to flow through it. So we can find our resistance value by inserting our known values in the Ohm's law equation to give us: R = 10V/20mA (resistance = voltage divided by current) Or R = 10/0.02 which gives us 500ohms. If you look up the resistors available from your electronics supplier, 500ohms is not a standard value. So we look for the next highest value (or next lowest if it is very close). The available values are 470ohm, 510ohm or 560ohm. 510ohm is the closest match and should be used. If we want to find out the actual voltage drop across the LED with a 510ohm resistor, we can use Ohm's law again. This time we have resistance and current so the formula becomes V = I x R. That is V = 0.02 x 510. That gives us 10.2V across the LED. As we have a 12V supply, that leaves 1.8V across the LED which will be sufficient in this case. It will also prolong the life of the LED and probably last indefinitely.

Summary:

To calculate a resistor value,

R = (supply voltage - LED voltage) divided by LED current expressed in amps.

So our above example becomes:

R = (12-2)/0.02

= 10/0.02

= 500.

Note: the LED current should be expressed in amps. So 20mA = 0.02. (or 20 divided by 1000).

Example 2:

We have a 9V battery, red LED and need to find the resistor value.

R = (supply voltage - LED voltage) divided by LED current expressed in amps.

So our example becomes:

R = (9-2)/0.2

= 350

See the circuit diagram for the 9V example below.

Simple LED circuit for model railways

What is a resistor?

A resistor is a semiconductor device that "resists" the flow of electricity. They are many different types - here we will focus on the "carbon film" or "metal film" versions. There are also various power ratings (expressed in Watts). For most modelling applications, a 1/4W carbon film resistor could be used.

As these components are not polarised, (ie: current can flow through them in either direction), it does not matter which way around they are installed in a circuit. The only identifying marks on them are colour codes - so that their resistance value can be identified. 3 or 4 bands are marked close together, with a gap, followed by a gold or silver band. The first 3 or 4 colours represent the value, with the gold or silver representing the "tolerance" of the value. The tolerance refers to the amount the value may vary from the stated amount. That is, a value of 100 ohms, with 5% tolerance, may be anywhere from 95 ohms to 105 ohms.

Model railway carraige lighting:

Now you may wish to add marker lights to a locomotive or the last vehicle of a train. It is not that difficult. The relatively simple circuit below is one method.
Without going into too much theory, it works as follows:
Electrical pick-ups from the wheels are used for the power source. The track power is then fed to the 4 diodes that form a "bridge rectifier". The bridge rectifier changes AC waveform into DC. In this application, it ensures that regardless of the track polarity, DC, pulsating DC or DCC etc, that we have a known power source polarity ready for the LEDs.

A capacitor "smooths" out the incoming power. This helps keep the LEDs working for brief fluctuations in power, like dirty tracks or traversing points/turnouts.
The next component is a 5V regulator. Its job is to keep a 5V output, regardless of the input voltage. So if 7, 9, 12, 15 or 20V comes in, 5V comes out. Below about 6V, the regulator ceases to function correctly. Likewise, they also have a limit of maximum voltage, and this varies with different models/manufacturers. Generally around 30V is the maximum. So this 5V regulator is fine for model railway use.
The next components are the resistors and LEDs. You could have a number of resistor/LED strings in parallel. For this particular voltage regulator, the maximum current is 100mA. So up to 5 LEDs, (each 20mA) could be used. If a 1amp regulator was used, 50 LEDs could be used in this fashion. That wouldn't be the most practical method to wire them up, but is used to illustrate the point.

Lighting circuit diagram

    Parts list:
  • 1N4002 diode or similar (or 4 for bridge rectifier, or W04 [or similar])
  • 1000uF electrolytic capacitor (lowest voltage rating for smaller size)
  • 78L05 voltage regulator (this is a small, 100mA version)
  • LEDs as required
  • *Resistors to suit LEDs (use 150ohm for the circuit above)
*Resistor values depends on the LED. For a 2V LED at 20mA, a 150ohm resistor is perfect. For a 3V LED at 20mA, a 100ohm resistor is required. As a safe bet, a 150ohm resistor could be used for any LED, the difference in brightness is hardly noticeable. One resistor required for each LED.

Useful tools:

I came across this site http://www.rocketdownload.com/program/resistor-calculator-143083.html where you can download a handy resitance calculator. It also graphically shows the colour codes and more. Helpful for beginners.

© Robert Parnell

browser BACK buttonRobert's Trains home page