Using PWM pins to pilot 2 LEDs


my first post here. My electronic skills are a bit rusted and need a quick help on this.

I'd like to know if it's possible to pilot two different led from the same PWM pin and if it will work as I expected.
(I've attached a diagram, but if not available LED A is connected from Vcc to PWM pin and led B is connected from PWM pin to ground, both with a current limiting resistor)

I think that with this configuration if the pin is set to 0 led A will be at it maximum brightness while B will be switched off.
Increasing the output values I increase brightness of led B while reducing that of led B until when I set output to 255 when I will have led A off and and B at max brightness.

Is this analysis correct ?


Yes, that's correct.

Thanks. :slight_smile: