Powering 5V RGB LEDs from Vin pin when supplying power from USB?

mojibake

New member
I'm wondering if I could use the Vin pin to power WS2812B or APA106 RGB LEDs (which need 5V on the VDD pin) when powering the Teensy 4.1 using USB.
There will be 24 or so LEDs in my design.
When I power the Teensy with USB, I'm reading 5V on the Vin pin with my multimeter. Could I use that to power my LEDs?
In my circuit I'm using a logic level shifter (HCT125) to convert 3.3V logic to 5V, I was planning to use a digital output pin (3.3V logic) to send data to the DIN pin of the 5V RGB LEDs via the logic level shifter.
I'd prefer not to add an extra circuit to power those LEDs, doing everything directly from the Teensy would be nice and simple.
Could I simply connect Vin to both pin 14 of the logic level shifter, and VDD pin of my LEDs?

I'm really quite inexperienced with building circuits so any tips/tricks/ideas are welcome!

(LED label is connected to a digital output pin on the Teensy, 5V is -currently- coming from a Raspberry Pi)
Screenshot 2024-06-12 at 19.49.13.png
 
Could I simply connect Vin to both pin 14 of the logic level shifter, and VDD pin of my LEDs?
No, not really. 24 LEDs, each consuming ~60mA when outputting white light, adds up to nearly 1.5 amps. That's too much for the Vin pin (even if the USB host could supply it).
A separate 5V power supply is the way to go.

Paul

PS. why is R1 470kohms? Shouldn't that be 470 ohms?
 
R1 at 470K will not work. The ideal resistor depends on the type of wire you use, but normally you would want 50 to 200 ohms.

Placing the resistor physically close to U1 is better than placing it close to the LEDs.

You might also want to add some power supply capacitors.
 
No, not really. 24 LEDs, each consuming ~60mA when outputting white light, adds up to nearly 1.5 amps. That's too much for the Vin pin (even if the USB host could supply it).
A separate 5V power supply is the way to go.

Paul

PS. why is R1 470kohms? Shouldn't that be 470 ohms?
Thanks for your reply.

Good to know, thanks. I'll have to figure out how to add a 5V power supply to my design to drive the LEDs.
I won't be running the LEDs at full power btw, in my breadboard setup a brightness of 100 (in the range 0-255) is more than enough for me.
I'm not completely done with my design, the maximum amount of LEDs will be somewhere between 24 and 40.

And wow, I just spotted the mistake in my schematic, 470kohms should be 470ohms. Thanks for pointing that out!
The resistor value of 470ohms is from this article: https://learn.adafruit.com/adafruit-neopixel-uberguide/basic-connections
Screenshot 2024-06-12 at 21.00.34.png

On the breadboard, everything seems to work ok with a 470ohms resistor.
 
Another factor to consider is some of the WS2812 (neopixel in Adafruit speak) LEDs can work fine if the data pin is 3.3v but the power pin is 5v. Some cannot do this and you need to use a level shifter to convert the data pin to 5v (you need to use a fast enough level shifter for the ws2812 protocol). In addition, some WS2812 LEDs can run on 3.3v (from the Teensy 3.3v pin) or 3.7v (from a lipo battery) instead of 4.5-5.5v volts that the original WS2812B LEDs required.

Obviously you cannot run these at full power due to the amperage available, but if you keep the maximum power down, you can run some LEDs from either power source. I've run 32 LEDs (2 16 LED rings) with 3.3v power with SK6812 LEDs if I keep the maximum level to 30 or less (30 for the sum of the red, green, blue, and white channels).

IIRC, 32 LEDs with a max power of 30 is 0.4 amps, but I may be mistaken. If you use VIN instead of 3.3v, you can go to somewhat more LEDs or higher power. IIRF, 3.3v gives you 0.25 amps, VIN gives you 0.5 amps, and the Teensy 4.x uses 0.1 amps.

In general, if the LED uses SK6812 chips (from szledcolor.com), it can run at 3.3v - 5.5v power, and the data signal can be 3.3v. The original WS2812B chips would only work between 4.5v and 5.5v and the data also had to be at the same voltage as the power. I don't know if WS LEDs have been improved. Adafruit has switched to SK6812 around 2016. I recall the SK based LEDs also were friendlier to people with problems with blinking lights, since the PWM cycle was faster. Here is one comparison I found via a google search:
 
R1 at 470K will not work. The ideal resistor depends on the type of wire you use, but normally you would want 50 to 200 ohms.

Placing the resistor physically close to U1 is better than placing it close to the LEDs.

You might also want to add some power supply capacitors.
Yeah, 470K should've been 470ohms in my schematic. I guess I messed up converting breadboard <-> kicad schematic.
I'm designing a PCB and the resistor will be SMD.

The complete circuit will look something like this: Teensy 4.1, 16 push encoders, around 24(?) switches, some HC165 shift registers to capture the inputs, RGB LEDs, a slide potentiometer, and two decoupling capacitors (for the 3.3V and 5V lines). Plus a Raspberry Pi with a 5inch DSI touchscreen.
I was using an ESP32 but I want to switch to Teensy because of it's DSP/audio capabilities, so I might add audio in/outs in the future.

Regarding the resistor value, my knowledge is limited still, so I just copied what was said in the Adafruit article. Should I pick a 50-200ohms resistor instead of a 470ohms resistor?

Placing the resistor physically close to U1 is better than placing it close to the LEDs.
Thanks for the tip! I've written it down.
 
Last edited:
Another factor to consider is some of the WS2812 (neopixel in Adafruit speak) LEDs can work fine if the data pin is 3.3v but the power pin is 5v. Some cannot do this and you need to use a level shifter to convert the data pin to 5v (you need to use a fast enough level shifter for the ws2812 protocol). In addition, some WS2812 LEDs can run on 3.3v (from the Teensy 3.3v pin) or 3.7v (from a lipo battery) instead of 4.5-5.5v volts that the original WS2812B LEDs required.

Obviously you cannot run these at full power due to the amperage available, but if you keep the maximum power down, you can run some LEDs from either power source. But I've run 32 LEDs (2 16 LED rings) with 3.3v power with SK6812 LEDs if I keep the maximum level to 30 or less (30 for the sum of the red, green, blue, and white channels). If you use VIN instead of 3.3v, you can go to somewhat more LEDs or higher power.

In general, if the LED uses SK6812 chips (from szledcolor.com), it can run at 3.3v - 5.5v power, and the data signal can be 3.3v. The original WS2812B chips would only work between 4.5v and 5.5v and the data also had to be at the same voltage as the power. I don't know if WS LEDs have been improved. Adafruit has switched to SK6812 around 2016. I recall the SK based LEDs also were friendlier to people with problems with blinking lights, since the PWM cycle was faster. Here is one comparison I found via a google search:
Nice info. I'm not entirely sure yet which LED I'll use. It's a pity that the APA106 are in 5mm/8mm only, I would've loved 3mm. I'm thinking about using WS2812 SMD LEDs with a 3mm diameter light guide, but for simplicity I might just go with the APA106's.

Regarding power, I'll probably just figure out how to get a 5V power supply onto my PCB, maybe I'll keep my current setup of leeching 5V from the Raspberry Pi that is running next to the Teensy.

Thanks for your input!
 
Back
Top