Current (mA) control for WS2812 RGB LEDs through FastLED?

For a project, I purchased 5 LED RGB 5mm addressable WS2812. Link to WS2811 (practically the same? on the polulu website for documentation and information!

Using the FastLED library, I tested one LED by connecting the VCC to 5v, ground to ground, and DIN (input) to digital pin 2 and changed colors, albeit never at max 255,255,255 brightness (only going to 200, 0, 0 for while). It worked fine, and I had no problems with it, even adding a button and the like. LED and MCU (Arduino Micro) are all fine.

However, upon further research, I saw that the WS2812 LEDs draw “50mA” at max power and that the Arduino micro has a max (absolute max) of 40 mA per I/O pin and 200 mA total (I think?). Does this mean I risk messing up the microcontroller (arduino micro), digital pins and/or RGB LEDs? Or is this not relevant info?

I apologise, I am a newbie to Arduino and had no idea about milliamps or voltage or anything until yesterday! If you have the time, could you explain how this works? Why is mA drawn from the digital pin? Or isn’t it at all?

How come nothing happened to my microcontroller or LED? Even though I worked at more current than recommended.

Now, I furthermore saw that the FastLED library has code in it which can limit the mA and volt draw. “FastLED allows you to cap the power usage of your leds. There's two ways to set the max power draw you want. The first is by specifying the voltage your leds will be running at and the maximum milliamps you want to draw:”

So, if I put it like this:

 // limit draw to 1A at 5v of power draw
   FastLED.setMaxPowerInVoltsAndMilliamps(5,38);

Would this work without messing anything up, correct or wrong? Or do I need to do anything with the practical analog/physical circuit? Resistors? I just have it connected to VCC, ground and digital pin2. Would this just make them not as bright?

What if I were to connect other LEDS? If I had them all at 38 max then, does this mean I would be able to run 5 RGB LEDs through the board as the total is 190mA?

An extra question I have is that in previous project I have run two SG90 servos with no problem or resistors, and vibrators (75 mA?) etc with furthermore no problems. How come nothing happened and all worked fine with dozens of hours of tinkering? Lucky?

Thank you very much in advance!

the power was not coming from an IO pin, but straight from the 5V pin. There is almost no power drawn from the I/O pin that controls the color, it's a digital signal

That being said, the 5V pin takes its power from the current source of your board (likely your USB connector) or goes through a regulator if you power differently through a Jack on UNO or MEGA, or Vin for example. That regulator has builtin limit in what it can provide and if you draw too much there will be a voltage drop and your arduino will reboot (or your regulator will "burn" if it has to convert 12V to 5V and you expect lots of amps)

So best way is to power the LEDs (or Servos) directly with 5V, not going through your arduino; just connect GNDs so that the control pin signal is referencing the same GND.

1 Like

There is almost no power drawn from the I/O pin that controls the color, it’s a digital signal

I see, so what does this mean practically?

That being said, the 5V pin takes its power from the current source of your board (likely your USB connector)

Yes, I am using an Arduino Micro with a USBC (small) to normal USB connected to my desktop, so I assume power is coming from that?

So best way is to power the LEDs (or Servos) directly with 5V, not going through your arduino; just connect GNDs so that the control pin signal is referencing the same GND.

External power source I take it? I do not have one of those, sadly? Or can I get them in some easier way?

Nonetheless, even if its the "best way" is it safe to power it the way I am doing right now, (VCC, ground and digital pin from the arduino with no other components) through the arduino micro? Just for a single LED RGB for testing and the like? Is the miliampere not relevant here?

Hi,
You might want to take a look at this tutorial here. Each WS2812 uses roughly 60mA at full power, because each LED has three separate ones inside (red, green, and blue), each using ~20mA. You could do two of the colors at full brightness like 255,255,0 or such. What would work best, is a separate +5V DC power supply to power the LEDs, not using the Arduino as a power source. What I do, is use a USB port plugin and a usb to pin breadboard module I designed, had printed, and put together.

what does this mean practically?

that you don't need to worry about the command signals coming from the digital pins, they are not used for powering the LEDs. it's just a command.

so I assume power is coming from that?

yes, and through your Arduino very thin solder mask going to the 5V pin. I would not plan on drawing more than 300/400mA from that pin to stay safe

External power source I take it?

if you can split the power into two wires in parallel, one going into the Arduino, one going into the devices, and if your power is strong enough, then it will be easier. The current going to the devices won't have to go through the Arduino and you'll be able to draw 1 amp for example if you power from a smartphone charger

you can find ready made "USB MALE A TO BARE WIRE" cables

is it safe to power it the way I am doing right now, (VCC, ground and digital pin from the arduino with no other components) through the arduino micro

Yes, 1 LED connected to 5V/GND and command coming from 1 pin is safe, even at full brightness it will draw 60mA from the 5V pin which is not a problem. I would say you are safe up to 4 or 5 LEDs (300mA at full brightness)

1 Like

Thank you very much for a detailed answer!

Yes, 1 LED connected to 5V/GND and command coming from 1 pin is safe, even at full brightness it will draw 60mA from the 5V pin which is not a problem. I would say you are safe up to 4 or 5 LEDs (300mA at full brightness)

Great, that is good! I only plan to use 3~~ at best for a showcase.

If you may, how come that this 5V pin can handle as you say 300/400 mA? Am I misunderstanding something with the digtal pins handling 40mA and the "entire arduino" being capable of 200mA~~ or is this a separate thing I am conflating? Like, perhaps the 200 mA only being for the I/O pins (all together) and the 5V pin being 300-400mA as you mention being separate?

You understood correctly that your digital pins have a max max at 40mA and to be safe you should stay well below that, so 20mA is recommended and the µC can indeed deal with about 200mA (that's a bit of a shortcut, it depends on ports your use etc) but the 5V pin is not a digital I/O pin coming from the µC, it's managed through on board circuitry

if you power through USB, you are feeding 5V, so it goes (almost) straight to your 5V pin. As USB provides 500mA, that's the max you can draw from the 5V pin, but some current is needed as well for your Arduino so if you want to save 200mA for the Arduino, don't draw more than 300mA from the 5V pin for example (simplified but good enough probably for your needs)

if you power through Vin, then you have a some circuitry and a regulator that will give you the 5V. if the power supply that's plugged on Vin can deliver more Amps, then you can get more power out of the 5V pin but as you go through the regulator and other components, you have some other limitations that come to play.

1 Like

I believe that makes sense! Thanks for the schematic and explanation!

Cheers!

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.