I'm trying to design a circuit to connect with an Raspberry Pi and have no idea what I'm doing... apologies in advance for terrible descriptions of my problem.

I have some 1 watt LEDs (max fowrad voltage = 2 - 3.4 V, max forward current 350 mA).

I also have an RPi 3B+ model with a breadboard extension, which can deliver 3.3V or 5V with a max current of 50 mA supposedly.

I want to be able to selectively turn on one of three-six LEDs in a parallel circuit using some python code I've developed. My idea was to have a constant current LED driver split off into 3 transistors which are connected to the RPi and also connected to the LEDs. I was hoping this would allow me to select which circuit to activate based on the RPi GPIO outputs. I've attached a crude schematic diagram of what I was going for.

the questions are as follows:

  1. is this going to work?? I'm a chemist by training and trying to do this for a project and don't want to electrocute myself/burn my flat down

  2. the driver I bought supplies 12-24 V at 300 mA, which I now realise is between 4-5 times greater than the volts I need to drive a single LED... I was wondering - can I stick a resistor before/after the LED and the return to the driver? or someway of bringing the circuit voltage up to 12V for the driver to function? or is the best option to buy a different driver?enter image description here

Thanks for any help! happy to provide more info if necessary.

  • \$\begingroup\$ So, if you turn off blue and red, all the current will flow through the UV LED and possibly destroy it. The current has to flow somewhere in this type of circuit. \$\endgroup\$
    – Andy aka
    Commented Jun 18, 2020 at 13:11
  • \$\begingroup\$ Thanks, yeh that's the issue I imagine I'm facing. As I understand it, if I'm not supplying any power from the RPi GPIO pins to the transitor, current won't flow so I can selectively turn on a single LED out of the 3. but I need to drain the excess volts somehow to stop the LED blowing up. \$\endgroup\$ Commented Jun 18, 2020 at 13:17
  • \$\begingroup\$ And don't forget that BJT transistors are different from MOSFETs. You'll need a proper resistor at the base pin to prevent small "explosion". \$\endgroup\$
    – rosmianto
    Commented Jun 18, 2020 at 14:33

2 Answers 2


The LED powersupply you have is simply not the right thing.

It is a constant current powersupply.

It will try to always force 300 milliamperes of current through the load (the LEDs.)

To regulate the current, it varies the voltage:

  • If the current is too low, it will raise the voltage to force more current to flow.
  • If the current is too high, then it will lower the voltage so as to force less current through the load.

Your powersupply has limits, though. Its voltage can only vary between 12V and 20V.

That voltage is in all cases higher than the voltage your LEDs are rated for - just connecting the LEDs to that powersupply will destroy the LEDs.

That type of powesupply is intended to be used with multiple LEDs in series. If you put 7 of your LEDs with the 2V forward voltage in series (total of 14V,) then the regulator will work properly and supply 300 mA to the LEDs.

You have a few options:

  1. Get a constant current supply with a voltage range that includes the forward voltage of all your LEDs.
  2. Stack multiple LEDs in series for each color so that the total forward voltage for each color is within the working range of the powersupply you already have.
  3. Put zener diodes in series with each LED such that the sum of the zener voltage and the LED forward voltage is within range of the powersupply.
  4. Get a constant voltage powersupply (5V) and put a series resistor (or other current limiter) in series with each LED.

A series resistor as you have in your sketch is normally used with a constant voltage powersupply to limit the current.

In your case, the powersupply itself limits the current.

If you had a constant voltage powersupply of 12V, then a single resistor would not work properly for all LEDs. It would allow a different current for each color LED.

The way you have your NPN transistors would not work. The transistors should be between the LED and ground.

As you have it arranged, the signal from the Pi (3.3V when high) at the base of the transistors cannot reach the needed 0.7V above the emitter voltage (sum of LED forward voltage and the voltage drop across the resistor.)

The LEDs will not light, of only dimly.

Worse, you have no resistor between the transistor bases and the Pi GPIO pins. That would damage either the transistors or the GPIOs - Murphy's law dictates that the GPIOs on the (relatively) expensive Pi will sacrifice themselves to rescue the (relatively) cheap transistors.

  • \$\begingroup\$ Thanks that was beyond helpful - I decided to buy another driver since they are pretty cheap which has a 3-12 V supply, I may need to swap out the red LED for something with a slightly higher forward voltage, but I'm ok with that. \$\endgroup\$ Commented Jun 18, 2020 at 16:09
  • \$\begingroup\$ and just to clarify, if I move the transistors after the LEDs and put a 220 ohm resistor between the GPIO and the NPN base, I should be good to go? \$\endgroup\$ Commented Jun 18, 2020 at 16:10
  • \$\begingroup\$ 220 ohm, maybe 1k. Not critical, but you need to keep the current from the GPIO low. The Pi is reated to safely deliver 16mA per GPIO, and no more than 51mA through all GPIOs at a time. 220 ohms give you about 15mA per pin. \$\endgroup\$
    – JRE
    Commented Jun 18, 2020 at 16:16

A few problems:

  1. You need a current-limiting resistor in each branch containing an LED, not a single resistor shared between all of them. The resistor should be sized such that the 'excess volts' (as you put it) divided by the resistance gives you the expected LED current.

  2. The NPN transistors need to go at the bottom of the LED-resistor-transistor series chain so they can function properly as a low-side switch.

  3. Your LED driver doesn't have enough current output to supply a single LED let alone multiple at the same time. You'll have to invest in an LED driver that can supply the total of all LED currents.

  4. The way you have your circuit set up, the current from the LED driver changes as you switch in and out LEDs. So you don't want a constant-current LED driver. You want to use a constant voltage LED driver instead. Just a regular AC-DC power adapter should be fine as well (as long as it meets the voltage/current requirements).

  5. Reduce the LED driver output voltage. All excess voltage that isn't dropped across the LED is dropped across the current-limiting resistor, producing nothing but waste heat. A 5V supply will do you much better than a 12V in this application. If you have 6 LEDs each requiring approx. 400mA, you need a 5V supply capable of delivering at least 12W.


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.