Mirroring RGB led to external LED strip in 0.7.0-rc.3


@RWB, only if you mirror the RGB led or use led signalling. With onchange(), you should be able to implement the Neopixel stuff as you have it. It should be easy to test. However I caution you to use a small number of Neopixels so as to not make refresh time very long.


@RWB, how does RGB.setBrightness(0) with subsequently setting the desired pinMode() work for you?
Not sure whether the r,g,b components of the onChange() handler will be altered with brightness, but they shouldn’t.
However, if you reuse any of the RGB pins as OUTPUT, you’ll see some flickering on the onboard RGB LED.


@ScruffR @peekay123

I think I have this figured out now after playing around some :slight_smile:

@Oizom_dev I changed the order of the code some to get this working with the v0.7.0-rc.4 firmware.

Note that I’m using the RGBW Neopixels so I have changed the LED type but the code layout is all you should need to copy if you’re using the RGB version.

If you want the LED to start working as soon as the Photon starts up then you need to use SYSTEM_THREAD(ENABLED); .

If you don’t then the Network status LED only starts after the WiFi connects and starts breathing cyan if you’re using Automatic mode. Semi-Automatic and Manual modes start the Network status LED instantly without SYSTEM_THREAD(ENABLED);.

The problem I was having is that the docs didn’t talk about how to turn off the or take over the RGB led pins 27,28,29. other than calling RGB.control(true); which also keeps the RGB.onChange function from working.

Turns out all you have to do is set their pin mode and then they stop driving the Photons’ RGB LED while the RGB.onChange function keeps working which is what you need for supplying the Neopixels the current
RGB values for current system status.

My simplified code is below for anybody who may need it :robot:


#include "neopixel.h"

// Initialize objects from the lib

#define PIXEL_COUNT 8            //8 LEDs
#define PIXEL_PIN D2             // Digital pin for communications
#define PIXEL_TYPE SK6812RGBW    // Set for RGBW LED's / Change if your using regular RGB Neopixels. 

#define NETWORK_LED 0            // Pixel Number were using to show the Network Status LED Pattern. 

// Initialize objects from the lib
Adafruit_NeoPixel strip(PIXEL_COUNT, PIXEL_PIN, PIXEL_TYPE);

void setup() {
   // disable on-board RGB LED on Photon/Electron / You can also set these pins for other uses. 
   pinMode(RGBB, INPUT_PULLUP); 
   strip.show(); // Initialize all pixels to 'off'

void loop() {

void ledChangeHandler(uint8_t r, uint8_t g, uint8_t b)
  strip.setPixelColor(NETWORK_LED, g, r, b, 0); // Change this if your using regular RGB leds vs RGBW Leds. 


That’s what I meant with this


although the “side effects” of RGB.control(true) and RGB.setBrightness() were somewhat “unexpected” :blush:

But I’d not use INPUT_PULLUP or INPUT_PULLDOWN due to the hardwired components - INPUT alone should do.


Cool, I was just looking at the functions provided in the Doc’s and there is nothing there about what pin names to use to take control of the RGB pins which is why your comments didn’t make sense until I saw Bdub’s old post here about how to turn off the RGB led in the post below. That’s where I got the Input Pullup idea.

Any idea why he chose Input_Pulldown? Instead of just INPUT?

Also, can we have the docs updated so other people know there is another way to use the RGB pins other than RGB.control(true);


Pin names would be RGBR, RGBG and RGBB

He says it’d be redundant but did it anyway - no idea why, but @bdub might be able to clarify :wink:


It’s all working perfectly now :smile:

I also solved the original posters issue with this working with the latest version of the firmware so you can mark this as Solved if you want.