I am trying to make a studio light that will have 12 segments. Each segment will look like this:


(10 LEDs (3.2v, 20mA), 2 connected in series then parallel to each other segment, 5 150 ohm resistors, 9 volt battery for mobility)

I plan to connect multiple batteries in parallel to achieve a constant voltage and accumulate current to power the LEDs for a longer period of time.

I've tested a single segment of this circuit and I am impressed with the results. What I want to do next is connect a Raspberry Pi to the circuit. I have not posted this on the Raspberry Pi forum because this question is geared more towards the actual electronic components. I understand that I need a component to connect the LEDs to the micro controller. I was thinking about using some sort of transistor or relay, but I have no idea how to pick the appropriate one.

Another problem arises because I am using 9v battery that will connect with a 5v circuit. I know some transistors require a common ground, and I do not know how else to connect it. I've found another answer here: Creating a common ground. I am unsure if the Raspberry Pi will be damaged by doing this.

To the point: How can I control multiple segments of lights with the Raspberry Pi.

  • 2
    \$\begingroup\$ RPi has 3.3V I/O, not 5V. \$\endgroup\$ – Ignacio Vazquez-Abrams Nov 7 '17 at 0:30
  • \$\begingroup\$ Also, R Pi is not a microcontroller - it's a full blown (albeit, minimal) computer. \$\endgroup\$ – Kurt E. Clothier Nov 7 '17 at 1:58
  • \$\begingroup\$ This Fritzing image may looks pretty, but is awfull. \$\endgroup\$ – mguima Nov 7 '17 at 18:48

NO DAMAGE WILL HAPPEN. To control each LED segment, you can use a MOSFET/transistor switch in the Battery-LED path, which is turned on/off by the raspberry pi. And yea, we will need a common star ground here. But, whatever current flows through the LED and resistor path, that current is NOT sunk back through raspberry pi to its ground. Instead, it is sunk through the external circuit of the transistor switch to the source of that current, which is the battery itself. So no damage will happen to our pi. Only the battery's current rating, and the transistor's current rating matter.

P.S This is something we have done at college :D


Short answer: yes, you will damage the raspberry pi, both because of the voltage and because of the total current. The Raspberry Pi GPIOs are barely able to drive an LED, but definitely cannot sink 60mA (9V / 150 ohms, I = V / R) and there is a limit on the total current driven by all GPIO pins (varies by RPI version).

Consider using a constant current LED driver (available from TI and others, take a look at the TLC59025) that drive many independent chains of LEDs using a low power SPI or I2C digital interface from the RPI. These chips also internally limit the current eliminating the series resistors.

  • \$\begingroup\$ Thank you so much for your answer. How exactly would I go about connecting the segments to the TLC5940? Would I have to rearrange the LEDs in any way? How would I power this? \$\endgroup\$ – red_kb Nov 7 '17 at 1:56
  • 1
    \$\begingroup\$ @ERN what do you actually know about electronics? It's hard to give you an answer if no one knows what you know how to do on your own.. \$\endgroup\$ – Kurt E. Clothier Nov 7 '17 at 1:59
  • \$\begingroup\$ As Kurt said, it is difficult to give you specific advise without knowing what your constraints are. I'm guessing you are looking for something you can assemble on a breadboard, so take a look at the MAX6971 and read the datasheet mouser.com/ds/2/256/MAX6971-90327.pdf. post comments with followup questions on anything you don't understand. \$\endgroup\$ – Dean Franks Nov 7 '17 at 2:12
  • \$\begingroup\$ I have some experience with electronics. I have worked with Arduino and Raspberry Pi before and I understand the fundamentals of electronics (eg Ohms law, Kirchhoff's laws, logic gates, etc,) but I haven't really worked on projects with complicated circuits. \$\endgroup\$ – red_kb Nov 7 '17 at 2:32
  • \$\begingroup\$ @DeanFranks I've look at the data sheet you've provided. I noticed it said the output is 55mA for each. Is that ok for 10- 10mm LEDs? \$\endgroup\$ – red_kb Nov 7 '17 at 2:57


simulate this circuit – Schematic created using CircuitLab

With 2V per LED at a desired 10mA current using 5000 mcd RED 5mm LEDS ( I have lots) 1V rise on Vol of GPIO results in 40mW per port.

Is important to realize ESR or RdsOn on CMOS has a wide tolerance but 3.3V max logic is 25 Ohms and 5Vmax logic is 50 ohms at 5V nom.

enter image description here

Some users (-1) fail to understand to voltage characteristics of driving LEDs in series with the Anode connected to a higher voltage.

With say a 100uA leakage to Vss via the diode clamp internal to CMOS logic on the output with the power off to CMOS the 9V battery will actually pull up Vss via the internal reverse diode to

  • Vss=Vbat-Vth x4 -Vf (diode)= 9-6.4-0.2 ~ 2.4V = Vss(off)

    ( Vth for Red is 1.6 to 1.8V while with 20mA Vf=2.1V on good parts.)

I see the questionable specs have changed to 55mA

If you exceed 20mA then you must add an Open drain switches ( or open collector)

Many come in 4 to 8 drivers per IC and can drive >100mA and are low cost. e.g. http://www.ti.com/lit/ds/symlink/am26c31.pdf not ideal but an example.

  • \$\begingroup\$ I've got 10mm LEDs by the way. Sorry I didn't mention this in the original post. \$\endgroup\$ – red_kb Nov 7 '17 at 2:33
  • \$\begingroup\$ If you insist on 5S 2P array then you need a 12V source. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Nov 7 '17 at 3:26
  • \$\begingroup\$ I am willing to rearrange the LEDs as necessary. \$\endgroup\$ – red_kb Nov 7 '17 at 3:30
  • \$\begingroup\$ You can only factor 10 with 5x2 or 2x5 then use a 5V USB pack \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Nov 7 '17 at 3:34
  • \$\begingroup\$ The design specs are a poor match for a simple solution. I would have dont it much differently with 10Cd 5mm LEDs and a diffuser film. \$\endgroup\$ – Tony Stewart Sunnyskyguy EE75 Nov 7 '17 at 3:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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