Individual LED brightness control

Hello All

I am attempting to create a lighting control system prototype using an Arduino Uno, LEDs, and photoresistors. My team and I have encountered problems in regards to INDIVIDUALLY selecting and controlling the brightness of an LED in an array with more LED outputs than the Arduino board holds. Will a demux work for my application? For example will I be able to program and wire it in such a way that will allow me to select one LED out of a group and individually control its brightness (with preferably 5+ steps of brightness)?

Questions for more specifics are welcome. I am a mechanical engineer on a team with an electrical and computer engineer, who although not available now, will be able to provide more details if necessary to answer the question.

Thank You

Willy S

There are several ways to do it.

One way is to get leds that are individually addressable. Then you use software to turn control each led, setting the red, green, and blue colors to the power level. One common system is the WS2812, that has 3 wires (power, ground, data). Each light is hooked up as a chain, and then you send a series of pulses out to control each light. One such example of this is the Adafruit neopixels system: Search Results for 'neopixel' on Adafruit Industries. You can set each neopixel pixel to 0..255 for each of red, green, and blue colors.

Adafruit sells neopixels in various setups: individual leds either for hooking up to a breadboard or sewing onto fabric, a ring of 16 leds, a stick of 8 leds, 8x5 panels, 8x8 panels, and strips of leds by the meter that you can cut to any length. You can chain neopixels together, by connecting all neopixels power/ground, and chaining the output data connection of the previous neopixel to the input data connection of the next neopixel. Note, as you get up to the hundreds of leds, you will need to worry about powering all of these leds and you will need enough SRAM on your Arduino to hold the entire state of the leds.

Another way is to use an i2c/spi pwm controller that can control multiple pins, using pulse width modulation to simulate varying the voltage. Again, Adafruit sells them (as do many other places). Here is a 16 pin i2c board: Adafruit 16-Channel 12-bit PWM/Servo Driver - I2C interface [PCA9685] : ID 815 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits and a 24 pin spi board: Adafruit 24-Channel 12-bit PWM LED Driver - SPI Interface [TLC5947] : ID 1429 : $14.95 : Adafruit Industries, Unique & fun DIY electronics and kits, Both i2c and spi, are ways to hook up remote chips to your Arduino. You can hook up something like 112 devices to an i2c bus, and the particular Adafruit device I mentioned has 6 address select pins, so you can address up to 992 different lights. I don't recall what the limits are for spi.

A third way is to use an actual digital to analog (DAC) circuit to vary the power. You can get i2c versions of these as well. For example the pcf8591 provides up to 4 analog inputs and 1 analog output. There might be DAC's that address a lot of pins, but I'm not aware of any. For just lights, PWM should be good enough, and you probably don't need a DAC.

Obviously when you get to more than a few lights, you need to worry about powering them independently from the Arduino.

willystober:
an array with more LED outputs than the Arduino board holds

Do you mean more than the number of analog outputs, or more than the total outputs? You could use software PWM to control the brightness of an LED on any digital I/O pin, and a Mega has lots of pins.

Hello, im in the same group as willy.
Here is more info,
We need to power 64 single color white LED's AND control their individual brightness. We have a MAX7219 led controller but that only lets us control the brightness as a whole. Those other things mentioned either are more for RBG LEDs if im right?

Im assuming all the lights need to remain on too, right?
The way I would go about this is by, to use the Arduino to switch between the LEDs very fast. So each LED value would be stored in an array, and you need constantly cycle through all of them to get the LEDs to light.
Now of course this alone will most likely turn the other LEDs off as its going through the cycles, so you will need to add capacitors and maybe diodes to prevent back feed. The capacitors should be able to hold the charge long enough to wait for the next cycle. Maybe use some 10uf to test a handful of LEDs first, and if that doesn't hold the charge long enough, use bigger caps.

Never mind

Ahh no, the lights power(on/off) and brightness are all controlled through user input. we can get the lights to turn on/off individually, but we are stuck on getting them to change brightness individually.

geereg12:
Hello, im in the same group as willy.
Here is more info,
We need to power 64 single color white LED's AND control their individual brightness. We have a MAX7219 led controller but that only lets us control the brightness as a whole. Those other things mentioned either are more for RBG LEDs if im right?

The i2c pwm controller would allow you to control the brightness of white lights. You would need 4 i2c pwm controllers to control 62 lights (you can have a max of 64 controllers and 992 lights on a system). With i2c, you need to use the 2 i2c pins on your Arduino (A4/A5 on the Uno, in the ICSP header on the Mega, etc.). You hook all i2c devices together, chaining SCL, SDA, ground, power.

The spi pwm controller can do 24 lights, so you would need 3 controllers. SPI uses 3 pins, and again which pins you use are specified on the board. I believe spi is faster than i2c, but it isn't as standard, so you might have issues if you have different boards on the same circuit.

The controller does the pwm on the board itself, so it means once the Arduino sets the brightness, it doesn't have to go back turning the lights on/off eacg a cycle, which would be problematic if the Arduino had to do it for 64 leds.

geereg12:
We need to power 64 single color white LED's AND control their individual brightness.

Do you have any choice about which Arduino to use? A Mega2560 has 54 digital I/O pins and 16 analog pins. On many Arduinos the analog in pins can also be used as digital I/O pins and I suspect that's also true of the Mega2560. In that case you could control all these LEDs directly from the Arduino. I assume you'd drive each LED via a transistor from a separate power source since that lot would exceed the Arduino's current rating.

If you're committed to driving them via the MAX7219 then you could use the SPI interface which will give you a pretty quick interface and see how fast you can soft PWM them individually. If you can achieve 100 Hz or so then flicker may not be a problem.

How are they currently connected?
What is meant by "array" of LEDs? ...like an 8x8 matrix? Etc..?

With the info given, here are just two possibilities (examples of things already mentioned) -

TLC5947 - 24 channel, 12 bit PWM controller with SPI interface. Daisy-chain-able (almost) forever.

MCP23017 - i2c 16 input/output port expander - Up to eight of these can be on same I2C connection.
**Edit - This is only ON/OFF....Oops!

1ChicagoDave:
MCP23017 - i2c 16 input/output port expander - Up to eight of these can be on same I2C connection.
MCP23017 - i2c 16 input/output port expander : ID 732 : $6.95 : Adafruit Industries, Unique & fun DIY electronics and kits

Though note, the MCP23017 only has on/off for each port. So to change the brightness, you would have to have the Arduino busily turning the lights on and then off. I would suspect that by the time you get the Arduino to be turning 4 sets of controllers on/off, you might start seeing some flicker, but maybe the Arduino and i2c are fast enough that most people won't notice. I will mention as the flicker rate gets slower, some people (including me) get sensitive to the flicker, and it can cause headaches..

Does the TLC5947 24 channel, 12 bit PWM controller retain the brightness level for each LED, or just turn them off?

So if I have 24 LEDs and I want each one to be set to a different brightness level, would I see all of them lit?
If so, I'm going to get some.

It might be a stupid question, but I like conformation before I buy my components.

MichaelMeissner:
Though note, the MCP23017 only has on/off for each port. So to change the brightness, you would have to have the Arduino busily turning the lights on and then off..

Nice catch. I updated previous post. Sorry 'bout that. :~

HazardsMind:
Does the TLC5947 24 channel, 12 bit PWM controller retain the brightness level for each LED, or just turn them off?

It should retain level.
From datasheet -

The TLC5947 is a 24-channel, constant current sink LED driver. Each channel is individually adjustable with 4096 pulse-width modulated (PWM) steps. PWM
control is repeated automatically with the programmed grayscale (GS) data.

ok we are going to try the TLC5947. Thanks so much for all your help.