WS2811 - LED Strip - I need so explaination

I am using the following code which appears to create the effect that I am looking for.

#include "FastLED.h"

// How many leds in your strip?
#define NUM_LEDS 104

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
#define DATA_PIN 12

// Define the array of leds

void setup() { 
       FastLED.addLeds<WS2811, DATA_PIN, RGB>(leds, NUM_LEDS);

void loop() { 

void sunrise() {
  // total sunrise length, in minutes
  static const uint8_t sunriseLength = 5;

  // how often (in seconds) should the heat color increase?
  // for the default of 30 minutes, this should be about every 7 seconds
  // 7 seconds x 256 gradient steps = 1,792 seconds = ~30 minutes
  static const uint8_t interval = (sunriseLength * 60) / 256;

  // current gradient palette color index
  static uint8_t heatIndex = 0; // start out at 0

  // HeatColors_p is a gradient palette built in to FastLED
  // that fades from black to red, orange, yellow, white
  // feel free to use another palette or define your own custom one
  CRGB color = ColorFromPalette(HeatColors_p, heatIndex);

  // fill the entire strip with the current color
  fill_solid(leds, NUM_LEDS, color);

  // slowly increase the heat
  EVERY_N_SECONDS(interval) {
    // stop incrementing at 255, we don't want to overflow back to 0
    if(heatIndex < 255) {

What I can’t get right is the following:

  • The LED’s nearer the power source are too bright with the ones near the end at the correct brightness. I understand why this might happen but I was wondering if there is a way to ensure that the brightness was similar irrespective of how far from the power source an LED is.
  • Also, the LEDs near the power source flicker MUCH quicker. I would like to get this more uniform too.

I feel that there is something that I am missing and/or not understanding.

Ok so I found the problem. I was using the following power supply, feeding the board via VIN and GND. When I plugged in a power supply via the Micro USB it all suddenly started working just fine. The power supply does register 5V and so I am at a lost as to why it would not work.

Think I answered my own question again

From the website

5V. This pin outputs a regulated 5V from the regulator on the board. The board can be supplied with power either from the DC power jack (7 - 12V), the USB connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the 5V or 3.3V pins bypasses the regulator, and can damage your board. We don't advise it.

I need to use the 12V feed and not the 5V.

The question I now have however is that when looking at LED strip examples, many diagrams have then powered via the same input as the arduino i.e. via VIN and GND. If this is the case then you can only put 5V in VIN as the LEDs are 5V.

More digging, while my power supply gives a 5V output is appears that it is not a clean feed :frowning: Alas that’s one happens when one tries to buy cheap.

OK, all sorts of things wrong here!

  • There are many different Arduinox, so you always need to explain which. Presumably a UNO, though this form is really useful only for experiments and demonstration. For practical projects (such as yours), the Nano is more useful.
  • The "Vin" is the input to a regulator, which has a minimum drop of about 2 V, so you need 7 V as minimum for reliable operation.
  • You cannot power anything of substance from the Arduino 5 V as an output when feeding it through the on-board regulator from Vin as drawing more than 50 to 100 mA will cause the regulator to overheat and (hopefully) shut down.
  • The advice you quote - the last sentence - is terribly misleading. You would certainly not attempt to power the 3.3 V terminal externally, neither safe nor effective. Feeding the 5 V pin is the proper way to power it from a 5 V regulated supply but note - regulated. It must never exceed 6 V and should indeed, be well-regulated. It is unwise to be feeding a 5 V supply into the 5 V terminal and connect the USB port to a PC at the same time as the external 5 V may interfere with the USB port. Given these caveats, powering the board with regulated 5 V by the 5 V terminal is the proper way to power it.
  • Powering with regulated 5 V by the USB port - such as from a USB "phone charger" is OK. It is limited by a "polyfuse" rated at about 500 mA but then the Arduino board itself should never draw more than that. You would have to be very careful about drawing current from the 5 V terminal when powering it this way - no more than about 300 mA.
  • Your LED strip is 104 LEDs long. Each can draw up to 60 mA, so the total draw could be 6.24 Amps. You need a power supply capable of at least that, essentially at least 8 A. This has nothing to do with an Arduino, you cannot in any way whatsoever "power" it from the Arduino. If you have a fully-regulated 5 V supply of 8 A then you can use this to feed the Arduino as well via the 5 V pin. Note that the two wires from the "DIN" (with the series resistor) and ground of the LED strip go together to the Arduino. Disconnect the power supply (and the LED strip) whilst programming through USB.
  • Now, the foil connections on the LED strip are not suitable to carry 6 Amps, so you must with reasonably heavy cable connect the power supply to at least both ends and the middle of a 104 LED strip. You will notice otherwise that the LEDs further from the power connection will turn distinctly yellow ("warm white"). This is because the blue in the LEDs requires a higher voltage so if the voltage sags, it will be the blue that dims more.