I’m using an Arduino Uno and a fastLed WS2812B. I have the leds set up correctly. Every 2 seconds, the lights pause of about a second and display seemingly random colors.

Does anyone know what's wrong?

My code:

#include <FastLED.h>

#define LED_PIN   7
#define NUM_LEDS  10


void setup() {
  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);


void loop() {
  for (int i = 0; i < NUM_LEDS; i++){
    leds[i] = CRGB(0,0,255);
  for (int i = 0; i < NUM_LEDS; i++){
    leds[i] = CRGB(255,0,0);
  • Is this on an Arduino or something else like ESP8266? – jose can u c Jan 12 '19 at 21:36
  • It is an Arduino Uno – Wes Summers Jan 12 '19 at 21:39
  • How are you powering the LEDs? – Majenko Jan 12 '19 at 22:50
  • I noted that each example in fastled library, ‘’clear’’ the array, after running ‘’show’’ function. Try with: leds[i]= CRGB::Black; after ‘’show’’. – leoc7 Jan 12 '19 at 22:57
  • what happens if you put FastLED.show(); and delay(100); after the for loop – jsotola Jan 12 '19 at 23:08

I have run the code on the Arduino simulator online. If it is working in the Arduino Simulator chances are less that it has to do something with the code itself.

Hence, also as the root cause was found to be about sharing the ground @Majenko

This is also one example of solving the problem step by step. validating one section after the other. using the simulator you can verify that the code is working fine. later, proceed to verify the hardware. I hope this helps.

You can verify the FastLED code here (you can modify the parameters)

enter image description here

  • Is this really answering the question? It seems to be saying what the problem isn't. – Nick Gammon Sep 2 '20 at 11:44
  • @NickGammon I too agree ☑️. I tried to show how I could deduce the root cause to be hardware and not the library or the code itself. The OP has also found the root cause to be hardware. – ArduinoFan Sep 2 '20 at 12:00

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.