OnChange RGB Handler - Common Anode or Common Cathode?

@peekay123, I’m getting my things mixed around. when using the OnCHange handler for the RGB does the RGB led need to have a CA or CK?

I think it needs the CK because of the analog writes, but I just want to be sure.

Thanks!

Since it’ll be your code it’s totaly up to you which kind you use, you just need to code accordingly.
For CK you’d use

  analogWrite(pin_r, r);

and for CA you’d use

  analogWrite(pin_r, 255-r);

The on-board RGB LED is common anode.

1 Like

This note is mostly about using Serial2 and the pads under the Photon, but it also has a section on using the onChange handler. It is indeed as ScruffR described.

1 Like

Thanks everyone.

@ScruffR do you know if its possible to disable the on board led but still use the on change handler? I have a battery operated device and will be using the electron, since power usage needs to be optimized i do not want to have 2 rgb lights on.

@wesner0019, the command for that is RGB.control(true)

I’m not sure, if that by default switches the LED off, but you could force it to off via RGB.color(0,0,0);.
But that might punch through to your own LED too.

If so you could try setting pinMode(RGBR, INPUT) (and RGBG/RGBB respectively).

1 Like

2 posts were split to a new topic: How do I disable the internal RGB LED?

A post was merged into an existing topic: How do I disable the internal RGB LED?

Hi @ScruffR, when I take light readings at night the RGB LED interferes as the system wakes from sleep and readings are taken. This thread has been helpful, but I wanted to ask whether RGB.brightness(0,0,0) is preferred over RGB.color(0,0,0) to achieve no light polution. Also, is all I have to do to implement:

void something()
{
RGB.control(true);
RGB.brightness(0,0,0);
RGB.control(false); //I understand that the 0 brightness would persist after relinquishing control.
}

Lastly, is the RGB control built in, or do I have to import a certain library for the above functions to work?

Thanks a lot!

@RobotChicken, I suggest using RGB.color(0,0,0) to turn off the LED. You something() code will turn off the LED briefly since you return control of the LED to the system immediately after turning it off. Instead, take control, turn off the LED, do your readings THEN return control of the LED.

The RGB LED library is built in. Look here:
https://docs.particle.io/reference/firmware/photon/#rgb

:slight_smile:

Thanks much @peekay123

1 Like

Hmm, I'm pretty sure that RGB.brightness() only takes one parameter and more importantly, this should also work after RGB.control(false) on the native RGB signals (sorry @peekay123 to contradict :wink: )

1 Like

@ScruffR, I like being kept honest :wink:

1 Like

Thanks @ScruffR, looking back at the documentation it does appear to be one param.

I ended up implementing RGB.color as it made sense to let the LED start blinking happily away again after reading the light by just releasing control. Will keep RGB.brightness in mind for future use cases.

Thanks guys.

1 Like