Hooking up multiple RGB LEDs while using a minimal number of PWM pins on an Arduino? [closed]

StackOverflow https://stackoverflow.com/questions/15829409

  •  01-04-2022
  •  | 
  •  

I currently have an anode RGB connected to the 11, 10, & 9 PWM pins on my arduino. However I would like to add 3 more LED's to my project, but I don't want to necessarily take up every single PWM pin. Is there a way for me to hook up all 4 LED's while using the minimum number of pins? Keep in mind that I do want to use all 12 resistors for the 4 LEDS. Oh and all the LEDs will do the exact same thing (They all will be red, and all turn blue, etc) if that helps.

Here's how my board looks right now:

enter image description here

If anyone could help me out, that would be awesome!!!! Appreciate the help!

P.S. I attached the .fzz file so that if any of you would like to edit the schematic image, it would be super easy. click here.

有帮助吗?

解决方案

if there are all doing always the same, just connect them parallel, which means that you just put your second LED into the breadboard right under the existing one.

If that is to much power consumption wit 4 LEDs you have to use a transistor as amplifier. I would like to send youo a schematic, but I have no software to draw such. However, using a transistor to amplify the arduino output is quite a common thing...

Hope I could help!

其他提示

Whether you connect the RGB LED in series or in parallel off the same PWM lines, your main issue will be current drawn from each PWM line. Arduino lines typically support up to 40mA from each GPIO pin (with a 200mA maximum/chip). LEDs usually allow up to 20mA for each channel if you want maximum brightness. This means that you really shouldn't put more than two channels on each GPIO pin, if you want maximum brightness for each LED. This calculation tells you that the only sensible result is to use transistors to actually power the LEDs, and use your Arduino to control the transistors. Here's one description of how to do that, but I am sure you can find plenty more.

As far as wiring the LEDs, you really have two options here:

I prefer the parallel configuration: it is easier to debug, and easier to ensure the proper current limits for all LEDs. There is also the issue of LED forward voltage: most leds need between 1.8V-3V of forward voltage across them to conduct. If you only have 5v to work with, then you can string only up to two LEDs in series before you cannot ensure a proper forward voltage across each one. If you try to put three in series you may either get the result that some of them are dimmer then the others or the whole thing doesn't light up at all.

Depending on the granularity of your timing on the LED(s), what you can do is the following:

Arduino => shift register => transistors => Resistors => LED pin.

Look at the bitshift out libraries out there for the Arduino. This will make it so that you are only using a few of pins: clock, signal, and latch.

You can daisy chain the serial-in, parallel out registers to increase the number of LED(s) you can control in this fashion. What would happen then is this: you send a stream of bits which represents which bits you want to turn on/off, then toggle the latch to update the values. In this manner, you can PWN drive a good number of tri-color LED(s) without risk of burning out an IO pin.

Note that timing becomes critical. As others have suggested, you can get dedicated RGB driver IC, but if you want to go with easy to find parts, the latching shift registers are a good way to go.

If you search, there are a number of good tutorials on PWM'ing over shift registers, as well as libraries.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top