Go Down

Topic: Individual PWM on Tri-color LED bar (Read 1 time) previous topic - next topic


I was happy to see the Tri-color LED bar worked happily with 5V from the Arduino and is more than bright enough. However (and try to excuse my limited electronics knowlege) the bar has a shared positive and individual grounds for each LED. Since the Arduino only does PWM on +5 I can only PWM one color at a time(to my knowlege). Is there a way to PWM ground rather than +5? Is this just a stupid question? I'd love to be enlightened.



Sure.  If the you apply 5 volts to the "ground pin" of an LED, it will turn off.  So if you PWM the ground pin, the higher the value passed to analogWrite() (i.e. the more time that the pin is at 5 volts), the dimmer the LED will be.  Just leave the shared power pin at 5 volts the whole time.


What dave just said is correct.
I'd like to add some "robustness" tips to his solution

usually a pin on the arduino board will be able to withstand at most 20mA whereas the ultra bright led operate , usually, at 50mA.
this means that in the long run the pin on the micrcontroller will burn.

The best solution is to use a power mosfet... like an irf520. Check the datasheet and connect the gate to the arduino pin, the source to ground and the drain to the LEDs cathode (-) the LED anode (+) is connected to whatever voltage you like... (up to the max supported by LEDs)



Ok I'll give that a shot. I was just thinking LEDs would only light up in one direction so I didn't bother trying that. I'll be newbing it for a while on this stuff. As for the mofset, I'll look into that, but since I don't need nearly the max brightness of the LEDs wouldn't tacking a resistor (I'm not sure of the rating of the one's in the lightbar) in line with it lower the amp draw below 20ma? Seems like 350ohm would do the trick at 5v. Again, total newb, so any advice you can give is useful advice.

Go Up