Hi folks, I've been struggling to get these lights working and ....

Hi folks,

I’ve been struggling to get these lights working and … any help appreciated.

I was just trying to use the example code blocks that come with the FastLED library to test them, but I’m getting erratic and inconsistent results. The colors across the lights are all over the place, and I get wild flashing. The LEDS don’t turn off when sent the color black.

I’m using an Arduino UNO compatible board, and have then set up as WS2812B string of lights.

And this is ALL the code FYR

Any help would be most greatly appreciated.

Cheers.

#include “FastLED.h”

#define NUM_LEDS 3

#define DATA_PIN 7

#define ON_TIME 10000
#define OFF_TIME 2000

// Define the array of leds
CRGB leds[NUM_LEDS];

void setup() {
Serial.begin(57600);
Serial.println(“resetting”);
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(20);
}

void loop() {
// Turn the LED on, then pause
leds[0] = CRGB::Red;
leds[1] = CRGB::Green;
FastLED.show();

Serial.println(“Red Green”);
delay(ON_TIME);
// Now turn the LED off, then pause
leds[0] = CRGB::Black;
leds[1] = CRGB::Black;
FastLED.show();

Serial.println(“off”);
delay(OFF_TIME); // Turn the LED on, then pause
leds[0] = CRGB::Green;
leds[1] = CRGB::Blue;
FastLED.show();
Serial.println(" Green Blue");
delay(ON_TIME);
// Now turn the LED off, then pause
leds[0] = CRGB::Black;

leds[1] = CRGB::Black;
FastLED.show();
Serial.println(“off”);
delay(OFF_TIME); // Turn the LED on, then pause
leds[0] = CRGB::Blue;
leds[1] = CRGB::Red;
FastLED.show();

Serial.println("   Blue   Red");

delay(ON_TIME);
// Now turn the LED off, then pause
leds[0] = CRGB::Black;

leds[1] = CRGB::Black;
FastLED.show();
Serial.println(“offf”);

delay(OFF_TIME);
LedsOff(OFF_TIME);
Serial.println(" Red ");
LedsOn(CRGB::Red, CRGB::Red, CRGB::Red, ON_TIME);

LedsOff(OFF_TIME);
Serial.println(" Blue ");
LedsOn(CRGB::Blue, CRGB::Blue, CRGB::Blue, ON_TIME);

LedsOff(OFF_TIME);
Serial.println(" Green ");
LedsOn(CRGB::Green, CRGB::Green, CRGB::Green, ON_TIME);

LedsOff(OFF_TIME);
}

void LedsOff(int aTime) {
for( int i = 0; i < NUM_LEDS; i++) {
leds[i] = CRGB::Black;
}

FastLED.show();
Serial.println(“…ALL OFF…”);
delay(aTime);
}
void LedsOn(CRGB color1, CRGB color2, CRGB color3, int aTime) {
leds[0] = color1;
leds[1] = color2;
leds[2] = color3;
FastLED.show();
Serial.println(" . ON . ");
delay(aTime);
}
http://www.aliexpress.com/item/WS2812b-5meters-DC5V-Pixel-RGB-color-led-strip-150LED-150IC-SMD5050-white-PCB-Non-Waterproof/32364846783.html

I suspect it’s a timing issue, but have no idea what to do about it…

Did you remember to connect the ground line between the leds and the UNO?

Are you by any chance powering the strip from the Uno? This sounds like a power issue. You should have a separate 5v supply for these strips while ensuring that the ground for the uno and the power strip are connected together.

Check out TWIT know how podcast https://www.twit.tv/shows/know-how/episodes/173?autostart=false they have many episodes with ws2812 and ws2811 with example code and video.

@1icri_Old_Account That could be it, although I tried having the ground through the uno to no result at all! I couldn’t get any lights happening.

That said, I’m definitely going to try that again when I get home from work tonight. Thanks.

@Dushyant_Ahuja I’m powering it separately, but the ground isn’t tied to the uno. Will try tonight.

@Peter_Hanse TWIT KH is why I started this. Like I’ve got SO much free time on my hands to be playing with this. Thanks for the response

Yes both power supply ground and uno ground need to be tied together to give comon ground. Had same issue using esp8266 spark thing with ws2812.

Not having the ground tied together will nearly always give you random results. Ground provides a common reference to both the uno and the strip.

Possible wrong init?
FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
Try:
FastLED.addLeds<WS2812B, DATA_PIN, RGB>(leds, NUM_LEDS);
or:
FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);

To complete the loop here (literally) it was the usual… “is it plugged in” check that fixed.

Ground wasn’t tied between the LEDS & the UNO.

Many thanks for all your help folks.