Controlling multiple RGB leds with PWM from a Atmega328P using one transistor per color

atmegaledrgbtransistors

I want to be able to control 9 RGB leds, each color from a potentiometer.
Each color needs 20mA, so when all the colors are present the leds will need 540mA (9*3=27, 27*20mA=540mA).

My RGBs leds are common cathode so between the micro controller and the anode for every color y will put a transistor(TIP31C), with this configuration:

enter image description here

Do you think it will work? or I will need another voltage source? since I am giving just 5v to the micro controller.

Thanks for any advice in this project.

Best Answer

Yes, this will work, but don't forget to use different resistors for different colors, because each color has different voltage.

But my opinion is to connect LEDs serially and use higher voltage (but you need to use other LEDs with NO common wire) then you get much better efficiency like example:

schematic

simulate this circuit – Schematic created using CircuitLab