3
\$\begingroup\$

I've been browsing this forum and the internet now for a couple of days and what I thought would be an easy side project turned into a (for me) quite complicated matter.

I'm planning to build a mood light that consists of 12 common cathode rgb LEDs with each colour being controlled by an Arduino's PWM pins.

In this diagram that has been posted here a while ago I found pretty much the outline for all that I want to do: enter image description here

My research took me so far to understand the basic matters of a needed external 12 V Power source and the fact that I'd have to wire the LEDs parallel with respective resistors on each. What I would need help with is what transistors to choose and what resistors for them:

Should I use normal PNP transistors or a MOSFET? Are there specifically recommendable versions of each? And which resistors would I need in front of the transistor?

Important to me is, that one can control the individual colours smoothly and that there is not so much heat generation that I'd need a sink.

I'd appreciate any help,

Cheers Tim

\$\endgroup\$
3
  • 1
    \$\begingroup\$ I bet you don't have to be too picky - you're not dealing with a ton of power, a lot of "general purpose" transistors should work fine here, and you could make this work with either BJTs or MOSFETs. \$\endgroup\$
    – Greg d'Eon
    Commented Jan 28, 2015 at 23:23
  • \$\begingroup\$ Note that if you use 12V AND PNPs, then you will have a problem turning them off from a 5V arduino. That diagram looks designed for 5V to the LEDs. \$\endgroup\$
    – pjc50
    Commented Jan 28, 2015 at 23:29
  • \$\begingroup\$ What wattage are the LEDs? | Why 12V - are they 12V input or ..." | Part number and/or web link would help heaps | As pjc50 says - you cannot "pull down" the gate of base of a transistor that is on the 'high side' using an Arduino's 5V or 3V outputs - the transistors need almost 12V applied to turn OFF which you have not got. |You can use an additional transistor per channel to provide 5V to 12V conversion - with the bonus that PWM drive now becomes "normal" with high = on and low = off. Or you could use 3 optocouplers for the level shifting. \$\endgroup\$
    – Russell McMahon
    Commented Jan 29, 2015 at 0:26

2 Answers 2

3
\$\begingroup\$

Looks good to me, except:

If your 12V supply shares a ground with the Arduino, then you'll have a hard time turning the LED's off. That's because the Arduino outputs either 0V or 5V, which still leaves you 7V driving the transistors. (through the base resistors, so you shouldn't blow anything up)

If you have separate supplies, one 12V and one 5V, and one of those is isolated/floating, then you can connect the positives together like the old positive-ground automotive standard. Just make sure you know good and well what voltage the Arduino's negative rail ends up at because the programmer will still assume that that's ground.


Or, you could keep the negative ground to avoid confusion and do this instead:

schematic

simulate this circuit – Schematic created using CircuitLab

Q1, R1, and R2 form a level shifter for Q2, which is the same as you have already:

  • When Q1 is off, R1 pulls Q2's base all the way up to 12V, turning it off also.
  • When Q1 is on, it makes a voltage divider between R1 and R2 that turns Q2 on.
\$\endgroup\$
2
  • \$\begingroup\$ Why couldn't you control the LEDs with an NPN transistor on the negative side? \$\endgroup\$
    – user20574
    Commented Jan 29, 2015 at 6:06
  • \$\begingroup\$ Because they're common cathode. If they were common anode, then that would be the natural way to do it. Either way, the common terminals are connected internally to a single pin, so you can't really change it. \$\endgroup\$
    – AaronD
    Commented Jan 29, 2015 at 7:03
1
\$\begingroup\$

Just make sure the transistor can source enough current to power all the LEDs, MOSFETS would probably be better since there will have a lower voltage drop across them and they won't heat up as much, but either will work.

As AaronD said, the 5V from the Arduino won't be enough to turn off the PNP transistors (or MOSFETS). They will be on any time the base is more than 0.7 V below the emitter, 5 V is not high enough. I would usually use an NPN to drive each PNP, that way I can use standard logic voltages. Also, power transistors tend to have lower current gain than signal transistors, so you need a lot of base current. It is better to have another transistor supply this.

\$\endgroup\$
3
  • \$\begingroup\$ Already a big thanks to everyone here who quickly pointed out the problem with the different voltages. I did not consider that. But I just realized the fact that 5V will be enough for each of the rgb LEDs anyways and I'd only have to adjust the individual resistors. Than I'd only need enough amperage in the overall circuit to supply 12*3*0,20 mA = 720 mA. I know that the arduino cannot supply that much but with a 5V Battery or Power Adaptor the diagram as shown above should be fine right? \$\endgroup\$
    – Tim
    Commented Jan 29, 2015 at 0:19
  • \$\begingroup\$ In theory, yes. But consider that BJT's also have a finite saturation voltage, kinda like another LED. Look that up and see if you still have enough headroom for the current-setting resistors. \$\endgroup\$
    – AaronD
    Commented Jan 29, 2015 at 7:09
  • \$\begingroup\$ Or, you could use P-channel MOSFET's. Similar to PNP BJT's, but zero drive current at DC (basically a capacitor), and low resistance when on instead of a voltage drop. \$\endgroup\$
    – AaronD
    Commented Jan 29, 2015 at 7:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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