-1
\$\begingroup\$

I'm just starting with arduino, and want to light up 2 RGB leds (common cathode), and just think that the only thing I nedd was connecting them in parallel, no extra parts (my mistake), then I read about the max current of the ardunino pins, and found out about driving leds with transistors.

I have been reading about this in here and al around the web (can't post more :p ), my set up is simpler, just 2 leds in parallel, but I want to make sure I won't blow up my ardunino.

When I was driving one led directly from the arduino, I was using HIGH to turn on de led, now I will have to change the logic to light de leds on LOW.

First, is this set up correct? and Second there is a simple way to drive de 2 leds.

connecting common cathode rgb with npn transistors

Each pwm pins in the ardunino (9, 10 and 11) connect to base on each of the NPN transitors (one per color), emmiter of all transistors go to 5v, and collector of each transistor go to respective color on both leds. Common cathode on both leds go to ground.

I plan to use 2N3906 transistor for this.

\$\endgroup\$
  • 3
    \$\begingroup\$ Welcome to EE.SE, James. We can't tell from your diagram as it's a wiring diagram and we use schematics to show the function of the various components, their part numbers and component values. There's an schematic button on the editor toolbar. When you draw your circuit out you should find it clarifies your thinking. \$\endgroup\$ – Transistor Jun 22 '16 at 14:46
1
\$\begingroup\$

You have the general idea down. PNP transistors used to switch 5V to the anodes of each channel. This inverts logic, which is simple to fix in code.

Your only problem is that you are missing a base resistor between each GPIO and the transistor base. Without it, you can fry the transistor.

At I'm assuming 20mA per diode based on your existing resistors, so two in parallel per color channel, your only switching 60mA. So an appropriate base resistor would be 1k ohms. Anything from 220 ohms to 1k will work. At 220 ohms, your pulling 19 mA per GPIO, the recommended max being 20 mA, which is fine.

And no, this is pretty much the simplest method aside from using more GPIO, or using discrete leds with individual cathode and anode pins per diode. Common Anode leds are a bit easier too, as you can use NPN or N-channel mosfet, which are more versatile at lower base or gate voltages.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.