12v Common Anode RGB LEDs

To set the mood: RGB LED :: mbeckler.org
And I've got an Arduino Diecimila.

First, in the circuit schematics section, the author explains that the common anode is connected to an external +12v power supply, and that the cathodes are connected individually to pins 9-11. From what I've been reading, pins 9-11 are +5v (at 40ma, if I recall correctly) so how is it safe to attach the negative terminals from the LEDs into pins 9-12 on the board with a +12v line on the other side?

Second, wouldn't the +12v external supply need to be grounded to the Arduino in some way for this to work correctly? Would that ground be the ground pins on the power pins on the board?

Third, since the Arduino can be powered by +12v, through the power jack, would it be possible, or appropriate to supply the board +12v and have the LED's common anode connected to Vin on the power pins instead of another external power supply?

Using USB power, I've attached my LEDs to the board with the cathodes in pins 9-11, and attached the common anode to +5v from the arduino power pins, and have gotten the red diodes in the LEDs to function as I would expect them to (as the red diodes in the RGB LEDs take less voltage to light than the green or blue) but I've been too afraid to try attaching them to +12v with external power on the board for fear of burning out the board due to my limited experience with the arduino platform.

tl;dr :-/
Is it safe to have the negative side of a 12v LED connected directly to pins 9-11 for pwm?

anode is connected to an external +12v power supply, and that the cathodes are connected individually to pins 9-11

Huh?

The schematic on that site shows the anode connected to Vdd (that's +5V) and it shows a 220 Ohm resistor connected (in series) between each cathode and its Arduino pin. Taking voltage drop across the LEDs into consideration, the current sunk by each Arduino pin is less than 20 mA.

I don't see +12V mentioned anywhere. Am I missing something? Or what?

Is it safe to have the negative side of a 12v LED connected directly to pins 9-11 for pwm?

If you have some kind of LED module or array that is rated at 12V, there will be a specification that tells you the maximum current at that voltage. It is not safe to connect such a device directly to the pin of an ATmega unless that current is less than the CPU specification. If it's a "regular" LED and not a module or array, it won't be specified at +12 Volts. It will be specified for some maximum current at a much lower voltage (maybe 1.2 or 1.8 or some such thing).

Here's why I say that it's not safe, even though the PWM may result in an average current that is within the CPU specification limits:

What if the program crashes (or hiccups) with one of the pins low. Then the maximum current will be flowing into the ATmega pin. That's not safe unless that is less than the CPU device specification.

Regards,

Dave

I'm sorry, I should've been more clear about the differences between the project on that page and my own setup. I referenced the article as it deals with common anode LEDs instead of the seemingly easier to work with common cathode LEDs.

He's using a single 5v LED without built-in resistors. I'm using a 12v LED strip, but still common positive (in this case, common anode, correct?) with built in resistors. Can I power the Arduino with 12v via the input jack, and have the positive end of the LEDs attached to Vin, and the negative end of the LEDs attached to the pwm pins without fear of burning anything on the Arduino out?

I wouldn't do it.

Regards,

Dave

I'm glad I held off on trying it then!

I can follow directions to build and solder anything with much ease, but I'm still learning how and why things work.

Do you have any suggestions on how to go about powering the LEDs and still having pwm control without burning up my board?

Thanks!

You could use your approach of 12V tied to Vin, then use a multi-transistor driver like a ULN2803 to connect to the cathodes of the LED's.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

seemingly easier to work with common cathode LEDs.

I can''t see why one is easer to use than the other, you are just sourcing current or sinking current, it's just the same.

Can I power the Arduino with 12v via the input jack

Yes

and have the positive end of the LEDs attached to Vin

Yes

and the negative end of the LEDs attached to the pwm pins

No because the maximum voltage you can apply to an arduino pin is 0.5v ABOVE the supply voltage which is 5V because the regulator cuts the 12V down to 5v before it reaches the arduino.

No because the maximum voltage you can apply to an arduino pin is 0.5v ABOVE the supply voltage which is 5V because the regulator cuts the 12V down to 5v before it reaches the arduino.

More specifically...even though the cathode side of the LED+resistor arrangement is close to 0V when the rated current is flowing, it floats to 12V when no current is flowing. Your sinking switch still needs to be able to handle full voltage (and the Arduino pins cannot). If you never turned the switch off, you might be able to power the circuit that way, but wouldn't it be boring?

if you are trying to control 12v LED strips from the Arduino just follow the instructions here
http://fritzing.org/projects/arduino-controlled-rgb-led-light-strips/

if you want to make something your self just get 3 logic level mofsets one for each color and make sure you hook them up right or you will toast the Arduino

if you are trying to control 12v LED strips from the Arduino just follow the instructions here
http://fritzing.org/projects/arduino-controlled-rgb-led-light-strips/

These look awesome, and I'll definitely keep them in mind! Though, first, I'd like to take some time to make my own circuit to drive my LEDs as a learning experience.

if you want to make something your self just get 3 logic level mofsets one for each color and make sure you hook them up right or you will toast the Arduino

I'll research and look into getting some mosfets, as well as a ULN2803 for my needs, perhaps I'll get both and learn about them!

Thanks!

The ULN2803 is a great chip and is quite useful but it won't be able to run more than 3ft of 12v rope light per channel (500mA/Ch) you have 8 on the ULN2803 and you can combine more then one channel to increase the output if needed
the nice thing is it is easy to wire just feed the inputs from the arduino output pins and the GND pin from the 12v supply and the arduino GND then connect the outputs to the (-) on your lights and the 12v + to the (+) on the lights