Help with Common Anode LEDS and PWM


First of all let me tell you that im a novice when it comes to electronics. I am trying to make a mood lamp with an RGB led with Common anode design. I can’t seem to figure out how to control the LEDs with PWM when they are common anode but have done it fine with common cathode. Am i missing something or is it not possible?

I have searched the forums but were unable to find what i was looking for although found several forum posts on RGB leds in common anode setup none seemed to state how it is done.

Any help would be greatly appreciated as i started a project thinking i knew exactly what to do and all of a sudden i feel lost :-[



This may seem obvious but, you have to keep the anode pin held high or at 5V. You can put a single resistor on the anode bin of the led and run the other pins directly, holding them low or at 0V. I assume that you are using the pwm function of the arduino and so this will work because the pwm is an oscillation of high and low signals.

If you have any other questions post a picture or a schematic of your project.

The "easiest" way I've done it was used some NPN transistors, connect ground to one side of the transistor, put the negative of the LED you want to use on the other side, and the middle pin, you control with PWM. But make sure you use a 1k-ohm from whichever PWM pin you're using to the middle pin of the Transistor.

lol :)

Thanks for the replies guys, i realised that i was trying to think too much about the code when really i didnt need to change much at all. In essence i was trying to reverse the code which broke it.