Hello everyone. I’ve read through numerous posts about RGB.onChange and Neopixel (only a handful, that I found, and I am coming up completely empty on getting anything working.
I wired up a regular RGB LED and implemented the RGB.mirrorTo code just fine. However, for cramming everything into a nice little enclosure, it’s much easier to use something a bit more convenient. I had a neopixel on a breakout in my drawer of stuff, so I decided to give it a try. Wiring it up and just addressing the neopixel, everything works great. Weird stuff happens when I try to use RGB.onChange though.
If I call STARTUP(RGB.onChange(ledChangeHandler));
it looks like the handler never fires. If I put RGB.onChange(ledChangeHandler)
inside of setup()
stuff just…breaks. The first time I tried it (adding it into my existing code) it would cause the onboard LED to alternate flashing green and white, and never kick out of that. The good news (I think?) is the neopixel would also blink (not green, just white on and off). After I gave up, I started from scratch and added just the neopixel code. Now if I keep it in setup
all it will do is fast flash green, like it’s constantly looking for a network signal. The neopixel does NOT flash or light up at all in this case. Anyone recently use a neopixel with a Boron to mimic the onboard LED? Here’s all of the not working code.
// This #include statement was automatically added by the Particle IDE.
#include <neopixel.h>
#define PIXEL_COUNT 1
#define PIXEL_PIN D5
#define PIXEL_TYPE WS2812
#define MIRROR_LED 0
Adafruit_NeoPixel led(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);
STARTUP(RGB.onChange(ledChangeHandler));
void setup() {
Serial.begin(115200);
led.begin();
//led.setPixelColor(MIRROR_LED, led.Color(0,255,0)); // used to make sure working
led.show();
delay(300);
//RGB.onChange(ledChangeHandler); // just completely breaks the board
}
void loop() {
}
void ledChangeHandler(uint8_t r, uint8_t g, uint8_t b)
{
led.setPixelColor(MIRROR_LED, led.Color(r, g, b));
led.show();
}