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