40 LEDs with Raspberry Pi

Hi there,

I hope this is the right place to ask! I’m working on a Raspberry Pi project and was hoping for some guidance or confirmation about my setup.

I’m driving 40 ultra-bright LEDs using 5 shift registers (74HC595). The LEDs are powered directly from the Pi’s 5V pin, and since they’re super bright, I’ve added 470-ohm resistors. The LEDs are rated for 20mA each, but I’ve limited the current with the resistors.

The setup is managed with a Python program that switches the LEDs on and off, with a maximum of 7 LEDs lit at the same time. The distance between the LEDs and the Pi is no more than 4 meters.

My main questions are:

  1. Does this pose any risk to the Raspberry Pi itself?
  2. I’m avoiding using an external power supply because I think it’s unnecessary for this setup. Am I correct?

One thing I noticed during testing is that if there’s a power failure, the Pi resets its pins, and all LEDs turn on until the script starts running again. I believe this isn’t a big issue since the current draw in this case should still be under 200mA. Do you agree, or is there something I might have missed?

I’d really appreciate any feedback or insights!

Thank you!

So, at some point the board will be required to provide 200mA from its 5V pin. What is the current rating for that pin and its associated components ?

  1. Tell us what model Raspberry Pi you are using.
  2. Post a schematic diagram of your circuit.

I am on a Raspberry Pi 4. Having also some older Pi3s so I am tempted to use them


sch.pdf (308.0 KB)

Actually I think with 40 LEDS the current goes to 255 mA

Well, that's a nice picture but it looks like it came from KiCad so why not post the schematic diagram?

How do you get down to 200mA? Do the ultra bright LEDs have a forward drop of Vf=2.7V so that 40*(5V-Vf)/470ohm=195ma ?

I have posted it. It is under the image!

Hm I am not sure about this. I get only this info

  • Diode type LED
  • LED diameter 3mm
  • LED colour white cold
  • Luminosity 10000-12000mcd
  • Viewing angle 20°
  • Front convex
  • LED lens transparent
  • LED current 20mA
  • Operating voltage 3.5...4V
  • Mounting THT
  • Chromatic coordinates x: 0.31; y: 0.32

I think it is this one

xxxx

The 74HC595 should be powered from 3.3volt when controlled with a 3.3volt processor.
The LEDs should have a common rail to 5volt (not ground).
Are you doing this?

Note the the 74HC595 has a total drive limit of 70mA. White LEDs have a Vf of about 3.3volt at their max rated current, but that drops to ~2.7volt at a fraction of that current.
Leo..

That has a forward voltage specification consistent with 5V and a 470ohm resistor and ~200mA:

> # R code
> (5-c(2.6,3.1,3.6))/470 *40
[1] 0.2042553 0.1617021 0.1191489

Thanks so much for the reply! I didn’t know this—super helpful. It seems like it works fine with 5V too, though maybe it’s a bit less stable?

I’m still a little unsure about setting up the common 5V rail when using the 74HC595 to drive everything. Doesn’t the IC take in current and then distribute it through its pins? Should I set it up like in the image I’m sharing?

For now I have basically I copied what I am seeing here

Yes it is less stable. You may find it works OK with one IC and not another or you may find that after put everything together with 40 LEDs, operation is erratic, intermittent and unpredictable.
If you are making a PCB, the TLC5916 would be a better choice. It will work with 3.3V I/O and does not require individual resistors for each LED and you can easily adjust the LED brightness.

Eh I wish I knew it earlier. I am trying now with my prototype with 3.3V. Everything looks good and there is I suppose much less current flowing so I might decrease the resistors value. I guess things should be ok with this setup. If someone could have a brief look at my schematic here it would be great. It's is going to be a permanent artistic installation so I try to make it robust! Thanks for all the support

Your LEDs have a maximum forward voltage (Vf) of 3.6V, the 595 can only output 3.3V at most (it will be less). That is 0.3V less than the LED V(f), so some of your LEDs may not turn on. You will need to hand pick the LEDs that work with your selected resistor values.

1 Like

Well, the circuit seems to operate well in prototype with 40 LEDS and the 79CH595 at 5V. I am never having more than 7 LEDS on at the same time. Of course now I am tempted to redesign and TLC5916 seems a great option.

TLC5916 should work also at 5V I guess and then I could still power everything from Pi itself.

One of the things that still I cannot explain is why the lights are turned on when I exit the python script. Actually, I noticed they blink when I approach the wires with my hands. Shouldn't the pins reset to a closed state?

No. You power the TLC5916 with 3.3V and connect the LED anodes to 5V.
VLED = 5V, VDD =3.3V

1 Like

Wonderfull! Thank you so much. So to make it clear

  1. The R-EXT defines the overall brightness.
  2. VLED (5V) and VDD (3.3V) can come both from the Pi itself I guess.
  3. No need for decoupling capacitors here?
  4. No need for resistors for each LED
  5. Code for controlling it the same as with 74HC595?

I think I will redesign, I have to redesign :face_with_peeking_eye:

  1. Yes
  2. 3.3V yes, 5V maybe
  3. No you still need a 0.1uF on each Vdd. (TI dropped the ball on this)
  4. Correct
  5. No there are Arduino libraries for the TLC5916.

Hm seems a bit hard to find it in a local store! Another option is to use ULN2803 along with 74HC595 or maybe a TPIC6B595. I will keep searching for the TLC5916

Will have to think about it