fill() function not working correctly on RGBw Neopixel strip

Post here about your Arduino projects, get help - for Adafruit customers!

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
rjenn2
 
Posts: 8
Joined: Thu Sep 22, 2022 3:22 pm

fill() function not working correctly on RGBw Neopixel strip

Post by rjenn2 »

I am trying to light a string of individually addressable RGBw LEDs red with no flashing, chasing, etc.. With the code I am using, the first LED lights up red, the second LED lights up green, and the third LED lights up blue. What am I doing incorrectly?

Code: Select all

#include <Adafruit_NeoPixel.h>

#define PIN 6 // input pin Neopixel is attached to

#define NUMPIXELS 4 // number of neopixels in strip

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

const int button = 9;
int buttonState = 0;

int relay = 12;

void setup()
{
pinMode(relay, OUTPUT);

pinMode(button, INPUT);

delay(500);

pixels.begin(); // Initialize the NeoPixel library.
pixels.show();
}

void loop()
{
buttonState = digitalRead(button);

delay(500);

if(buttonState == HIGH)
{
digitalWrite (relay, HIGH); // turn on relay
delay(100);

uint32_t red = pixels.Color(255, 0, 0, 0);
pixels.fill(red, 0, 4);
pixels.show();
delay(500);

digitalWrite (relay, LOW); // turn off relay
delay(100);
}
}
Last edited by adafruit_support_bill on Thu Sep 22, 2022 3:31 pm, edited 1 time in total.
Reason: fixed [code] tags

User avatar
adafruit_support_bill
 
Posts: 88093
Joined: Sat Feb 07, 2009 10:11 am

Re: fill() function not working correctly on RGBw Neopixel strip

Post by adafruit_support_bill »

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

You have defined your strip as NEO_GRB. Try defining it as NEO_GRBW.

User avatar
rjenn2
 
Posts: 8
Joined: Thu Sep 22, 2022 3:22 pm

Re: fill() function not working correctly on RGBw Neopixel strip

Post by rjenn2 »

Thanks! That fixed it.

Locked
Please be positive and constructive with your questions and comments.

Return to “Arduino”