Electronic – arduino – The Transistor Menace – Questions regarding an Arduino rgb LED project

arduinoledpwmrgbtransistors

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

Best Answer

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.