So I'm trying to simulate a BJT switch for an LED.

Here's the detail and how I setup the simatiomln.

  • Vsupply = 4.2 V
  • LED UV Vf = 3.6 V
  • Hfe = 100

Here's the simulation:

Falstad link, does it work?

falstad schematic

My calculations start from what I want to achieve: 20 mA for the LED. That makes Ic = 20 mA.

Calculate Ib needed for Ic = 20 mA:

Ic / Hfe = Ib = 20 / 100 = 0.2 mA.

Then calculate Rb for Ib = 0.2 mA:

Rb = Vrb / Ib = (Vsupply - Vbe) / Ib = (4.2 - 0.7) / 0.2 mA = 17k5

That's all.

I'm assuming, because I set the forward voltage of the LED to 3.6 V, that the transistor (Vce) will take up the rest (4.2 - 3.6) = 0.6 V, and 0.6 V * 20 mA would burn into heat, but apparently it doesn't work like that.

What am I missing here? Am I setting it wrong, is there some variable that should be added to the simulation?

The goal is obviously 3.6 V @ 20 mA at LED.

One thing I notice though if change the Rb to 470R, I get 3.6 V drop in the LED, but Ic = 730 mA doesn't make sense.


I messed up my LED-UV model. turn out I need to set "Current at Above Voltage" to 20 mA. I don't even know what it means, I think it's related to LED working slope, it should be called "Current at Forward Voltage Above" so as not to confuse.

enter image description here

In my previous model, I just set the "Max Brightness Current" to 20 mA, and leaving "Current at Above Voltage" value to default 1 A.

enter image description here

Below is the final circuit (I would put the current limiting resistor later).

enter image description here

  • \$\begingroup\$ You may need a constant-current boost converter to get enough voltage to power the UV LED over the full range of battery voltages if that's a typical Li-ion battery. hFE not the way to do it, as the answer below suggests. \$\endgroup\$ Sep 23, 2021 at 18:57

1 Answer 1


Hfe is an approximation for a transistor in the linear region, it doesn't apply to a BJT in saturation. You can use it to estimate a base resistance, but the characteristic curves will show you more detail.

You should not rely on the saturation voltage of a transistor to limit the current in an LED. It can vary quite a bit over temperature and from unit to unit (as will the steep LED I-V characteristic). You should add a current limiting resistor so that the LED current is less dependent on VCEsat, or design a constant current driver.

You want 20mA in the LED, so estimate or look up the saturation voltage of your BJT. Let's ballpark it at 0.3 V. You can start with the value of Rb that you calculated and adjust as necessary.

Next get the forward voltage of the LED at 20mA: 3.6 V.

So you have 4.2 V - 3.9 V or 300mV of headroom (as Spehro pointed out if this is a Li battery you don't have much room for discharging it.)

Pick a resistor of 0.3 V/.02 A or 15 ohms, add it in series with your LED. Now it should be easier for the BJT to saturate.

However, for a workable design you would want more voltage headroom.

  • \$\begingroup\$ thank you @John. could you please elaborate step by step to design it correctly? Surely gonna use current limiting resistor, but my problem remain the same, I couldn't get 3.6v at the LED, while already achieving 20 mA falstad. Is there anything wrong with my setup/sim? \$\endgroup\$ Sep 23, 2021 at 19:45
  • \$\begingroup\$ @AkbarNurPribadi I edited my answer- Your simulations setup is OK except that you need a resistor in series with your LED. \$\endgroup\$
    – John D
    Sep 23, 2021 at 20:00
  • \$\begingroup\$ Nobody makes a 3.6V LED. An LED part number has a range of forward voltages, some will be 3.4V and others will be 3.8V. Falstad picked about 3V. A simulation also does not allow the Lithium battery voltage to run down to 3.0V. I do not know if Falstad knows that a transistor does not saturate with its hFE base current, the base current for saturation is usually 1/10th the collector current. \$\endgroup\$
    – Audioguru
    Sep 24, 2021 at 0:14

Your Answer

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

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