# Use an LM317 as a Current Regulator

If you are making one of our 12 volt kits (Bright & Beautiful and The Interrogator) and you stick to the kit instructions, you will be rewarded with a brilliantly bright light circuit that will run and run (and run).
Even so, you should be confident in your ability to interpret the instructions for those kits correctly.

If you are about to step out of the box and take matters into your own hands, I urge extreme caution and remind you that you are on your own - this knowledge is offered with no guarantees or promises of safety or usefulness (...our disclaimer, that is).

I have made the information as simple as possible.
If you want to be totally sure of the facts, have a look at a manufacturer's data sheet - you could download this one here.

There is plenty of advice out there on the 'net. You will be able to confirm what is here, and maybe find out more too - please let us know.

This type of LM317 (there are a few different configurations, but they all do the same thing) appears to be a metal backing plate with a hole in it. Mounted on the plate is a black, plasticy box with three electrodes emerging from it. Obviously, the magic happens inside the little box, which, among other things, contains 29 transistors.
The whole thing is about 3cm long.

Pin 1 is on the left and is referred to as 'adjacent'. Pin 2 is in the middle and is referred to as 'out'. Pin 3 is to the right and is 'in'.

As a current regulator, the LM317 gives an output voltage 3v less than the input.
It needs one resistor to set the output current.
It can supply up to 1.5amps (as long as the power source can provide it).

The resisitor, R, is controlling the current. Its value can be calculated using;

 R = 1.25 i that is: resistance needed is 1.25 divided by required current.

For example, a red 'star LED wants 0.35 amps to work at its optimum performance.

 So R would be 1.25 0.35 = 3.57Ω

You should then examine the resistors available to you and chose the nearest higher value.

If you chose a 4.2Ω resistor from our 2 watt range, the current would be

 1.25 4.2 = 0.3amps.     This would be safe and still very bright.

Depending on your intended circuit, you may need to use 6 watt resistors, but stick to at least 2 watt in any case. Each of our 'stars' uses 1 watt, so our resistor has to be able to deal with the total wattage from the circuit as a whole.

If you were to put a 1.4Ω and a 2.3Ω (2 watt) resistor in series, that would give you 3.7Ω, which would give you 0.34 amps, which is a lot closer (and should cope with up to 4 watts in the circuit).

Check out the section on resistors if you want to know more about combining them.

If you were to overdrive your 'star', it'd have a much reduced life, possibly burning out at a really bad time (down a cave, on your bike in the dark...) but would be devilishly bright.

If I was gung-ho enough to try two 6.4Ω (2 watt) resistors in parallel (effective resistance of 3.2Ω at 4 watts), I'd be giving my 'star' plenty to think about with 390mA... I'd also be taking a great deal of care making a heat sink and/or paying close attention to the temperature of the LED, the LM317, the resistors and the power supply. This is not something that this site would recommend or consider, even for a moment...

Whatever combination of resistance you chose, here's an easier-to-understand wiring diagram:

 The negative of your power supply just wires direct to the negative of your circuit. And here's what it looks like with a 4.2Ω (2 watt) resistor in place.

The LM317 wants 3v of its own to run, so if you are planning on making a series array of 'stars', for example, with a 12v power source, you'll only have 9v left to play with. This usually means there's only enough voltage to run 3 'stars' in series. I have tried to run stars in parallel with an LM317, but the power through the resistor makes it very hot. If you are going to try something like this I'd suggest 6 watt resistors, or a big array that'll stand the power. Not that I'm suggesting you try this either, no sir, not at all.

If you've got this far, you might also like to try:

Using an LM317 as a Voltage Regulator - it's more complicated but can be very useful.