LM317 constant current LED driver
An LM317 with 62 ohms from OUT to ADJ holds about 20 mA through three red LEDs on 12 V; swap in a 9 V adapter and the meter barely moves. There is no microcontroller in it: the simulator solves the 7 parts as a circuit, so it runs the moment you press Run, and nothing needs compiling.
Teaching? Assign it to your class in one click.
Intermediate Runs in your browser. Free, and no account needed.
The parts retail for about $7.85. On Mokxi they're free.
How it works
There is no microcontroller in this one, so nothing is compiled: the simulator solves the circuit itself. The file in the editor is the notes that come with it.
// An LM317 constant current LED driver.
//
// There is no microcontroller here. Press Run and the simulator solves the
// circuit; the multimeter, on its DC current range, reads the LED current.
//
// HOW IT WORKS. The LM317 holds its OUT leg 1.25 V above its ADJ leg. Put one
// resistor from OUT to ADJ and take the load from ADJ, and that resistor
// always has 1.25 V across it, so the same current flows through it whatever
// the load is:
//
// I = 1.25 V / R = 1.25 / 62 = 20 mA
//
// (plus the 50 uA that comes out of the ADJ leg itself). That current goes on
// through the meter and the three red LEDs to ground.
//
// TRY IT. Change the adapter on the DC jack from 12 V to 9 V. The LM317
// takes up the difference itself, and the meter barely moves. A plain
// resistor in place of the LM317 (330 ohm for 20 mA from 12 V) would let the
// current fall to about 11 mA. That is why LED drivers are current sources: an LED's
// current climbs steeply with its voltage, and a voltage source would have to
// be set to a few millivolts.
//
// THE HEADROOM. The LM317 needs about 3 V across it, and the resistor 1.25 V,
// so from 12 V the string can take about 7.5 V: three red LEDs at about 2 V
// each, or two white ones at about 3 V. Change R1 for another current:
// 1.25 / 0.35 A is 3.6 ohm for a 350 mA power LED (and a heatsink).
Parts list
7 parts, plus the jumper wires and a bench instrument. The parts retail for about $7.85; on Mokxi they're free, and so are the instruments.
- 1 × Half breadboard
- 1 × DC jack and adapter
- 1 × LM317 regulator
- 1 × Resistor, 62 Ω
- 1 × Multimeter
- 3 × LED, red
How it is wired
7 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.
- DC jack and adapter pin V+; LM317 regulator pin IN
- DC jack and adapter pin V-; LED, red (3) pin C
- LM317 regulator pin ADJ; Resistor, 62 Ω pin 2; Multimeter pin A
- LM317 regulator pin OUT; Resistor, 62 Ω pin 1
- Multimeter pin COM; LED, red (1) pin A
- LED, red (1) pin C; LED, red (2) pin A
- LED, red (2) pin C; LED, red (3) pin A
Change it and keep it
Open it in the editor, change the circuit or the code, and keep your version in a free account.