0

NEO PIXEL RGBW - Unable to call the W
Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.

NEO PIXEL RGBW - Unable to call the W

by bturnermail on Sun Jan 06, 2019 6:35 pm

Hello,

I am working on an LED project where I have 6 Neo pixel Strips of 12 LEDS each controlled by different pins on a 'Pro Trinket 5V'

I have a very minimal understanding of the code which I am using because someone on another forum has generously written it for me. As I have started to actually build the project I realized I wanted to use RGBW instead of the original idea of just using RGB. I have everything wired together and fully functional except I cannot get the white LED to show. The general idea is to be able to call each strip to fade from one color to another and be able to change it accordingly, and also be able to turn all of them white as well.

I am looking for someone to help look over the code and find what I am missing from the equation.
Apologies for such a long code, but I do not know which section is causing me to not be able to call the white LED......

Any help with this would be greatly appreciated.

Ben

Also is there a code library where I could post this project upon completion? I am forever grateful for all the people who have posted there projects, but I don't know where the best place to put it would be.

Code: Select all | TOGGLE FULL SIZE
#include <Adafruit_NeoPixel.h>

const int NUM_PIXELS = 12;
const int NUM_STRIPS = 6;

// An array of the pin numbers for the strips
const int Pins[NUM_STRIPS] = {3, 4, 5, 6, 8, 9};

uint32_t CurrentStripColor[NUM_STRIPS] = {0};


// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
//   NEO_RGBW    Pixels are wired for RGBW bitstream (NeoPixel RGBW products)
Adafruit_NeoPixel Strips[NUM_STRIPS] =
{
  /* for some reason the colors are : Green, Red, Blue, White */
  Adafruit_NeoPixel(NUM_PIXELS, Pins[0], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(NUM_PIXELS, Pins[1], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(NUM_PIXELS, Pins[2], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(NUM_PIXELS, Pins[3], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(NUM_PIXELS, Pins[4], NEO_RGBW + NEO_KHZ800),
  Adafruit_NeoPixel(NUM_PIXELS, Pins[5], NEO_RGBW + NEO_KHZ800)
};

/* for some reason the colors are : : : ::Color(R, G, B, W);*/
const uint32_t Black = Adafruit_NeoPixel::Color(0, 0, 0, 0);
const uint32_t Red = Adafruit_NeoPixel::Color(0, 255, 0, 0 );
const uint32_t Pink = Adafruit_NeoPixel::Color(40, 255, 40, 0);
const uint32_t Orange = Adafruit_NeoPixel::Color(255, 100, 0, 0);
const uint32_t Yellow = Adafruit_NeoPixel::Color(255, 255, 0, 0);
const uint32_t Green = Adafruit_NeoPixel::Color(255, 35, 35, 0);
const uint32_t Blue = Adafruit_NeoPixel::Color(60, 20, 255, 0);
const uint32_t Purple = Adafruit_NeoPixel::Color(100, 0, 255, 255);
const uint32_t White = Adafruit_NeoPixel::Color(0, 0, 0, 255);

struct Fade
{
  byte stripIndex;
  uint32_t color;
} const Fades[] =
{
/*
    {0, White},

    {1, Red},

    {2, Blue},

    {3, Green},

    {4, Pink},
   
    {5, Purple},


    {0, Black},

    {1, Black},

    {2, Black},

    {3, Black},

    {4, Black},
   
    {5, Black},

   
 */
    {0, Blue},   
    {1, Blue},   
    {2, Blue},     
    {3, Blue},     
    {4, Blue},   
    {5, Blue},
   
    {0, Yellow},
    {1, Yellow},
        {0, Pink},
    {2, Yellow},   
        {1, Pink},
    {3, Yellow},   
        {2, Pink},
    {4, Yellow},   
        {3, Pink},
    {5, Yellow},     
        {4, Pink},
        {5, Pink},
        {0, Pink},
        {0, Pink},



 
  /*
  {0, Green},
        {2, White},
  {1, Green},
        {3, White},
  {2, Green},
        {4, White},
  {3, Green},

  {4, Green},



  {0, Black},
  {1, Black},
  {2, Black},
  {3, Black},
  {4, Pink},
  {4, Black},



  {0, Black},
  {1, Black},
  {2, Purple},
  {3, Black},
        {2, Black},
  {0, Green},
        {0, Black},
  {4, Black},

*/
 
 // ETC.
};
const byte NUM_FADES = sizeof Fades / sizeof Fades[0];


// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

void setup()
{
  for (int strip = 0; strip < NUM_STRIPS; strip++)
  {
    Strips[strip].begin();
  }
  setAllStrips(Black);
}

void loop()
{
  PatternOne();
}

void PatternOne()
{
  for (byte i = 0; i < NUM_FADES; i++)
  {
    byte index = Fades[i].stripIndex;
    crossFadeStrip(index, CurrentStripColor[index], Fades[i].color, 10UL);
  }
}

void setAllStrips(const uint32_t color)
{
  byte red = (color >> 16) & 0xff;
  byte green = (color >> 8) & 0xff;
  byte blue = color & 0xff;
  byte white = color & 0xff;
 
  setAllStrips (red, green, blue, white );
}

void setAllStrips(const byte red, const byte green, const byte blue, const byte white)
{
  // for each strip
  for (int strip = 0; strip < NUM_STRIPS; strip++)
  {
    setStrip(strip, red, green, blue, white);
  }
}

void setStrip(const byte index, const byte red, const byte green, const byte blue, const byte white)
{
  // for each pixel
  for (int pixel = 0; pixel < NUM_PIXELS; pixel++)
  {
    Strips[index].setPixelColor(pixel, red, green, blue);
  }
  Strips[index].show(); // Output to strip
  CurrentStripColor[index] = Adafruit_NeoPixel::Color(red, green, blue, white);
}

void crossFadeAllStrips(const uint32_t startColor, const uint32_t endColor, unsigned long speed)
{
  byte startRed = (startColor >> 16) & 0xff;
  byte startGreen = (startColor >> 8) & 0xff;
  byte startBlue = startColor & 0xff;
  byte startWhite = startColor & 0xff;

  byte endRed = (endColor >> 16) & 0xff;
  byte endGreen = (endColor >> 8) & 0xff;
  byte endBlue = endColor & 0xff;
  byte endWhite = endColor & 0xff;


  // for each step in the cross-fade
  for (int step = 0; step < 256; step++)
  {
    byte red = map(step, 0, 255, startRed, endRed);
    byte green = map(step, 0, 255, startGreen, endGreen);
    byte blue = map(step, 0, 255, startBlue, endBlue);
    byte white = map(step, 0, 255, startWhite, endWhite);
    setAllStrips(red, green, blue, white);
    delay(50);                                                 //changed "speed" to 20 this controls the fade speed
  }
}

void crossFadeStrip(const byte index, const uint32_t startColor, const uint32_t endColor, unsigned long speed)
{
  byte startRed = (startColor >> 16) & 0xff;
  byte startGreen = (startColor >> 8) & 0xff;
  byte startBlue = startColor & 0xff;
  byte startWhite = startColor & 0xff;
 
  byte endRed = (endColor >> 16) & 0xff;
  byte endGreen = (endColor >> 8) & 0xff;
  byte endBlue = endColor & 0xff;
  byte endWhite = endColor & 0xff;

  // for each step in the cross-fade
  for (int step = 0; step < 256; step++)
  {
    byte red = map(step, 0, 255, startRed, endRed);
    byte green = map(step, 0, 255, startGreen, endGreen);
    byte blue = map(step, 0, 255, startBlue, endBlue);
    byte white = map(step, 0, 255, startWhite, endWhite);
    setStrip(index, red, green, blue, white);
    delay(50);                                                 //changed "speed" to 20 this controls the fade speed
  }
}

bturnermail
 
Posts: 2
Joined: Tue Dec 29, 2015 2:30 pm

Re: NEO PIXEL RGBW - Unable to call the W

by franklin97355 on Sun Jan 06, 2019 9:07 pm

Which strips did you buy and are you sure they are RGBW strips? A photo would help.

franklin97355
 
Posts: 20127
Joined: Mon Apr 21, 2008 2:33 pm
Location: Lacomb, OR.

Re: NEO PIXEL RGBW - Unable to call the W

by bturnermail on Mon Jan 07, 2019 2:04 am

Thank you for your response!

I have taken everything apart from the breadboard and soldered it to a PCB board and haven't got it all together yet so I have made a diagram of the wiring. I didn't include in the diagram the resistors between the board and the Neopixels, and the capacitor on the power supply.

I have the RGBW 30 LED Strips, and I also thought I may have the wrong strips, but I did the strand test and the white was fully visible.

Many thanks!
B
NEW LIGHTBOX IDEA.pdf
(68.87 KiB) Downloaded 3 times

bturnermail
 
Posts: 2
Joined: Tue Dec 29, 2015 2:30 pm

Please be positive and constructive with your questions and comments.