I would like to make a circuit that will allow the 20 mA red LED to light up at an input voltage from 5 V. Input voltage will never exceed 30 V.

Should I use a Zener diode with a resistor? I saw some projects with a TL431, but I think it is not necessary, I just want to change input voltage from 5 to 30 V and get LED light up.

I drew a schematic. Is it correct?


I also found this regulator on JLCPCB parts. Will it fit my task?

From p13, "application: constant current regulator"

enter image description here

  • 2
    \$\begingroup\$ Welcome! Please simulate your circuit. At low input voltage, your 1k resistor will dominate and your LED will be dim. If you want constant brightness from 5 to 30 V, I would recommend a constant current source. \$\endgroup\$
    – winny
    Feb 28, 2023 at 12:33
  • \$\begingroup\$ I found this regulator on JLCPCB parts. Will it fit to my task?datasheet.lcsc.com/lcsc/… page 13, application: constant current regulator \$\endgroup\$
    – newson
    Feb 28, 2023 at 12:39
  • 1
    \$\begingroup\$ What is the minimal acceptable current that should flow through the LED? 20 mA with modern LEDs is very high for most applications. Maybe 5 mA or less might be acceptable to you. The lower you can make this figure the easier and simpler will be the design. Remember also that this site isn't a forum so, any circuit ideas you might have should be in the question and not left as comments. Also, once an answer is given, it's possible that any changes you make to your question (called moving the goalposts) might invalidate answer already given so, take special care in this area. \$\endgroup\$
    – Andy aka
    Feb 28, 2023 at 12:46
  • \$\begingroup\$ Thans a lot for your help, I completed main question with information from previous comment. I checked datasheet and i think that 5mA should be ok for my application. \$\endgroup\$
    – newson
    Feb 28, 2023 at 13:00
  • 1
    \$\begingroup\$ @winny - please check datasheet on page 13. Why can I use this regulator as a constant current regulator, when manufacturer add this application in datasheet? \$\endgroup\$
    – newson
    Feb 28, 2023 at 13:04

3 Answers 3


Your Zener circuit won’t deliver enough current at low voltage, and will be wasteful at higher voltage.

In the spirit of ‘good enough’ built from parts from the odds-and-ends drawer, this is a good job for a 2-transistor current limiter.

Such a limiter will maintain about 20mA (or whatever you set it to) throughput the input voltage range, with one Vbe drop of overhead.

Here's an example that limits to 18-20mA over the 5-30V range. I’ve modified it a bit from the classic 2-transistor limiter: the LED is on the high side, and there's a ballast resistor in series with it to take some of the IR drop from pass transistor (simulate it here):

enter image description here

The power dissipation in the pass transistor is still quite high (500mW at 30V) due to the IR drop it must take. You’ll likely need a heatsink as a consequence. (This would be the case with a regulator IC, too.)

You can do a couple of things to address this:

  • Reduce your required current

20mA is the continuous rating for the LED. LEDs can give usable illumination at much lower currents. High efficiency ones will be plenty bright enough at currents in the 1-5mA range.

  • Use multiple transistors in series

The above circuit can be modified to take the voltage drop across two pass devices, as below (simulate it here):

enter image description here

This spreads the IR drop approximately equally across the two devices. At 30V, the power dissipation in each transistor is split between the two as 250 and 280mW. Then you could avoid needing a heatsink.

(Note: this isn’t a ‘cascode’ current source per se. That’s a different circuit using 4 transistors.)

  • \$\begingroup\$ Note that this circuit takes the $V_{BE}$ as a constant, where in reality it has a negative temperature coefficient -- \$dV/dT = -2 \mathrm {mV}/^\circ \mathrm C\$ is close enough for practical purposes. So the current will vary by about 35% from -40C to +55C. If you're not worried about the variation over your operating temperature range, it's a nice simple circuit. \$\endgroup\$
    – TimWescott
    Mar 1, 2023 at 19:59
  • 1
    \$\begingroup\$ The voltage bias also influences this circuit. If the feedback is tied to a fixed voltage then it regulates more accurately. Cheap and cheerful, not perfect. \$\endgroup\$ Mar 2, 2023 at 19:34
  • 1
    \$\begingroup\$ "Cheap and cheerful, not perfect". Perfect description of the circuit, though. It's certainly going to be more than good enough for a variety of uses. \$\endgroup\$
    – TimWescott
    Mar 2, 2023 at 20:52
  1. Current limiters rated for half the power dissipation will be suitable for a prudent temp. rise of half the max rise, up to something like 125’C max.

  2. 20 mA x 30 V = 600 mW, which is enough to fry tiny current limiters so choose a better LED. Consider using a minimum current of 2 mA. Long-term metallization failures creep in below 1 mA in LEDs.

  3. The simplest and most elegant solution is a current limiter chip rated for 1 W, if you ignore the above. But this is not the easiest to find, nor the cheapest.

  4. 2 R’s + 2 NPN’ or a 3-terminal LDO regulator rated for 30 V and 1.25V/R = I gets you another current limiter, if rated for > twice your Pmax. (Conservative advice, because it will never stay at 25’C STP.)

  • \$\begingroup\$ Can you advice literature or such for "Long-term metallization failures creep in below 1 mA in LEDs."? I don't doubt it, but I'm curious. \$\endgroup\$
    – Ralph
    Feb 28, 2023 at 19:28
  • \$\begingroup\$ @Ralph. It was long ago from Philips and Broadcom that I recall who specified this. It seems to have vanished now and may have been solved. \$\endgroup\$
    – Hoagie
    Mar 1, 2023 at 15:49

LM334 with a single resistor would be the classic solution, and would work from 3.5V and up.

A 78L33 driving the LED through a resistor would work as well, although perhaps from 5.5V and up, not 5.0V.

If you're into tweaking things manually, then the circuit below would do the job as well, and could probably be adjusted to have a couple % stability across 4.5..30V and 20..50°C. With some care it could be stable to a fraction of a percent, and it has very good stability with respect to line voltage. Using higher gain transistor types improves performance. In practice this approach unnecessary overkill, but hey - it would be no fun otherwise :) It is a reasonable discrete precision current reference building block, though.

REF is a bandgap reference, providing 1.22V. It could be replaced by TLV431 for simplicty. It provides

  • reference voltage for CS1,
  • reference voltage for CS4, biasing the current mirror CM.

CS1's Q1,Q3 are a classic two-transistor fixed current source, using bandgap's voltage as a reference. Q2 provides VBE compensation for Q3, making Q2 and Q3 act as a temperature-compensated differential pair.

The voltage across the LED is used as a derived reference for:

  • CS2 biasing Q3,Q3,
  • CS3 biasing the bandgap.

R1 sets the LED current.

R3 provides base current compensation in CS1 - adjust for minimum current variation across the operating voltage range.

R6 adjusts the bandgap's output voltage. Adjust for 1.22V output.

R10 provides the startup current to get CM going.


simulate this circuit – Schematic created using CircuitLab

Good reference on practical discrete bandgap circuits:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.