1

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
CRGB leds[NUM_LEDS];
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);
 FastLED.show();
 delay(100);
 }
 for (int i = 0; i < NUM_LEDS; i++){
 leds[i] = CRGB(255,0,0);
 FastLED.show();
 delay(100);
 }
}
leoc7
6034 silver badges12 bronze badges
asked Jan 12, 2019 at 21:26
10
  • Is this on an Arduino or something else like ESP8266? Commented Jan 12, 2019 at 21:36
  • It is an Arduino Uno Commented Jan 12, 2019 at 21:39
  • How are you powering the LEDs? Commented Jan 12, 2019 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’’. Commented Jan 12, 2019 at 22:57
  • what happens if you put FastLED.show(); and delay(100); after the for loop Commented Jan 12, 2019 at 23:08

1 Answer 1

-1

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

answered Sep 2, 2020 at 11:24
2
  • Is this really answering the question? It seems to be saying what the problem isn't. Commented Sep 2, 2020 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. Commented Sep 2, 2020 at 12:00

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.