How. I have experience programming, and I can't understand what is going on with this simple code.
It's supposed to display a red circle, but it's alternating RGBW colors
These are the relevant excerpts. The rest is in the picture.
void loop() {
strip.clear();
colorWipe(strip.Color(255, 0, 0), 50); // Red
}
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, color);
strip.show();
delay(wait);
}
}
Any hints?
#include <Adafruit_NeoPixel.h>
#define LED_PIN 2
#define LED_COUNT 24
#define BRIGHTNESS 50
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRBW + NEO_KHZ800);
void setup() {
Serial.begin(9600);
strip.begin(); // INITIALIZE NeoPixel strip object (REQUIRED)
strip.show(); // Turn OFF all pixels ASAP
strip.setBrightness(50); // Set BRIGHTNESS to about 1/5 (max = 255)
}
bool done = false;
void loop() {
if(!done) {
strip.clear();
colorWipe(strip.Color(255, 0, 0), 50); // Red
done = true;
}
}
void colorWipe(uint32_t color, int wait) {
for(int i=0; i<strip.numPixels(); i++) { // For each pixel in strip...
Serial.println(color);
strip.setPixelColor(i, color); // Set pixel's color (in RAM)
strip.show(); // Update strip to match
delay(wait); // Pause for a moment
}
}
I can see in the console the color is always the same. But the ring... It's not respecting that.
I found the cause. And it's really strange for me. But changing NEO_GRBW to NEO_GRB solves the issue.
So, just RGB (without white) draws everything in red, as expected. Why the other configuration would behave so differently? I can live without knowing that, but it's really strange.
guillermuino:
Why the other configuration would behave so differently?
Because the library's indexing would be out by one.
Paul_B
September 27, 2020, 9:50pm
6
guillermuino:
Why the other configuration would behave so differently?
Because that is the configuration for GRBW LEDs which you do not have. Yours are GRB.
Is that not perfectly simple?