Fork me on GitHub

Project Notes

#092 LM317 Constant Current Power Supply

A low-power constant current source using the LM317

Here’s a quick video of the circuit in action:



The LM317 is typically used as an adjustable voltage supply as demonstrated in the LM317 project.

But it can also be used as a constant current supply. The details are hiding towards the end of the application notes in the datasheet, with little explanation. However this tutorial on YouTube does an excellent job of clarifying how it works.

So my intention here is to test a low-power constant current source to drive a variable number of LEDs with constant brightness.

Let’s set the design criteria to be around 2-3mA constant current. That’s far from max brightness for an LED, but enough to be definitely on.

Since the 317 will attempt to maintain 1.25V across output to adjustment pins, we therefore select an appropriate value for R1 such that (by ohms law) we get our desired current.

In my case, it seems 470Ω is a good fit. This should result in a constant current of 2.66mA.

Using some 3mm LEDs that have a forward voltage Vf of about 1.9-2V, that means a 9V supply should handle up to 3 LEDs in series at 2.66mA before we run out of voltage headroom (VCC - ~2V = 7V).

So how does it work in practice? Pretty much spot on! With 1,2, or 3 LEDs in series, the 317 holds the current at 2.71mA.

Some notes on the circuit:

  • The first DIP switch is a master on/off that will light LED1 when on. When off we get 0 current as is expected.
  • The second and third DIP switches selectively enable or bypass LED2 and LED3
  • The 10μF electrolytic capacitors smooth the power supply and are not really necessary for this circuit



The Schematic

The Build

With 1 LED on

The Build

With 2 LEDs on

The Build

With 3 LEDs on

The Build

Credits and References

Project Source on GitHub Project Gallery Return to the LEAP Catalog

This page is a web-friendly rendering of my project notes shared in the LEAP GitHub repository.

LEAP is just my personal collection of projects. Two main themes have emerged in recent years, sometimes combined:

  • electronics - usually involving an Arduino or other microprocessor in one way or another. Some are full-blown projects, while many are trivial breadboard experiments, intended to learn and explore something interesting
  • scale modelling - I caught the bug after deciding to build a Harrier during covid to demonstrate an electronic jet engine simulation. Let the fun begin..
To be honest, I haven't quite figured out if these two interests belong in the same GitHub repo or not. But for now - they are all here!

Projects are often inspired by things found wild on the net, or ideas from the many great electronics and scale modelling podcasts and YouTube channels. Feel free to borrow liberally, and if you spot any issues do let me know (or send a PR!). See the individual projects for credits where due.