RGB LED on Digital Pin

Is it possible to control the 3 legs of an RGB LED using 3 of a Core’s digital pins? If it is doable, would it be harmful to the device or LED?

(Yes, I am amateur!)

Oh, and I ask because alllll the examples I look at use Analog pins.

Thanks! :smile:

EDIT:

Oh, I think I know the answer. It is doable but since digital pins only allow High and Low, I can’t really produce too many different colors. So, it is better to Analog.

If this is correct, is there a problem to control ‘regular’ red LEDs with digital pins?

Again, thanks!

1 Like

Hi Eric!

The following pins can do PWM on the core: A0, A1, A4, A5, A6, A7, D0 and D1.

That means you can use any of the above pins to do variable brightness control of an LED. Remember to use a resistor or else risky killing your pin :frowning:

And if you are desperate you could even use the non-PWM pins.

While the PWM pins are the obvious and easiest choice (just do an analogWrite(D0, 123); for it) you would have to do your own soft-PWM by doing digitalWrite(D7, HIGH); and digitalWrite(D7, LOW); in very quick succession.

This approach is used for example in the RGBmatrixPanel library.

2 Likes