1

I'm trying to control several RGB leds individually. So far I've been able to control multiple RGB leds using only 3 PWM outputs using NPN transistors as shown here (pic below).

NPN Transistors approach

I would like to control each led individually in order to display different colors in each led. If I used the Arduino Mega, which has 12 PWM pins I could only control 4 different groups of leds using the approach mentioned above. It would be nice to be able to control them using the Arduino Uno or other boards with less PWM pins.

What would be a good solution for this? I've been taking a look to shift registers using ShiftPWM and solutions like the TLC5940 but I haven't got enough experience to tell which way would work better.

  • I do wish people would draw proper schematics. I can't work out head nor tail what is going on in that circuit. Use the TLC59116 - it's the best LED driving chip ever. – Majenko Sep 18 '16 at 17:12
  • simply because of availability, try the software solution first, then try the hardware one. – sassoPera Sep 18 '16 at 17:14
  • @guardabrazo If by good you mean cheap solution to control several RGB lights. Then you can use a 4017 decade counter to multiplex the RGB lights so control several RGB lights. with a single 4017 is about 20 times cheapper than the TLC59116 costing about 17 cents. With a few 4017's you can control more than 100 RGB lights. This would only use a on the Arduino.(including a few PWM pins). – qwerty10 Sep 18 '16 at 17:26
  • "Digital led strips" have individually colorable LED's. Thuis would be much more favourable as a tricky solution. – Paul Sep 19 '16 at 7:04
1

Here is a 1/2 software 1/2 hardware solution:

You actually have 6 pwm pins (from the silk screen notation in your picture). So you can control 2 RGB LEDs independently. If you added 4 more transistors that are used to gate the common 5v going to each of the 4 RGB LEDs you could control them in pairs. That is, you could turn on 2 independently controlled RGB LEDs and let the 6 PWM outputs control the brightness and color of each of the 2 for, say, 100ms. Then you could turn those off and turn on the other 2 independently controlled RGB LEDs for 100ms. During the switch, you would change the PWMs for the 2nd set of RGB LEDs. The draw back to this approach? You may start noticing the LEDs flickering. You may have to adjust the rate which you switch between the two pairs of LEDs. And, of course, it may not work as you expect it to.

Totally different approach:

You can use programmable RGB LEDs:

enter image description here

And use this Arduino software library. These types of RGB LEDs have the PWM build in. The Arduino sends out serial data to the first LED which strips off its RGB data. Then sends the data to the next RGB LED which does the same. So you can control many RGB LEDs using a single pin on your Arduino.

0

There is an alternative that gives you more PWM pins when using an Arduino Uno. You need a 74HC595 shift register which has eight additional output pins. By default, these pins are not PWM capable, however, with a library that I have developed they are.

You can then easily replace your analogWrite calls with something like that sr.set(i, val);. The parameter i indicates with shift register pin you want to update and val is a PWM value (from 0 to 255).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.