I'd only like to know if the following is doable with minimum effort: I'd like to create a custom 7x7 two-color LED matrix, where each row of LEDs can be dimmed separately and set to a certain color. The whole thing would ideally be controlled by an Arduino or some other microcontroller.

I have extensive programming knowledge, however my electronics knowledge is limited; I can interpret simple circuit diagrams, but that's about it.

How hard would the above turn out to be for someone like me and is that whole thing possible at all?

  • 2
    \$\begingroup\$ See electronics.stackexchange.com/questions/1150/… \$\endgroup\$ – Kellenjb Aug 16 '11 at 12:54
  • \$\begingroup\$ I would usually mark this as an exact duplicate of that question, but I think a good explanation is needed that the other question doesn't do a good job of providing. \$\endgroup\$ – Kellenjb Aug 16 '11 at 12:54
  • 1
    \$\begingroup\$ You say "each row of LEDs", does that mean you want all LEDs in a row to display the same color as each other at any given time? \$\endgroup\$ – Mike DeSimone Aug 16 '11 at 14:36
  • \$\begingroup\$ Hi all, thanks for your responses. It turns out I misunderstood the requirements: I do not need two-color LEDs. I better post a new question since this changes the topic quite a bit I guess. \$\endgroup\$ – Andreas Aug 17 '11 at 1:48
  • \$\begingroup\$ See electronics.stackexchange.com/questions/18330/… \$\endgroup\$ – Andreas Aug 17 '11 at 1:57

Disclaimer: I don't know the "right" way to solve this problem. But I'll present my thoughts on the approach to solving this, and people can add comments and up/down vote to hopefully massage this into an answer that helps you out.

The first thing I do is to think about the most brute-force solution. Let's assume your two colors are red and green. You'll therefore need 49 red and 49 green LEDs. You need to connect power and ground to each, as well as a current-limiting resistor, but let's only focus on connections for now since you want to use an Arduino. The cathodes for all 98 LEDs can be tied together to ground, and the other 98 can connect to your microcontroller.

Clearly, this doesn't work because you wouldn't have enough digital outputs to individually address each LED. And you want to change the brightness, so you'd also need several PWM outputs.

Footprint/aesthetics-wise, if you can get a bi-color LED that has the two colors you want, I would try to use one of those instead, and will assume that direction for the rest of this "answer".

Now we have a design with 49 bi-color LEDs, with all cathodes tied to common ground. You've got to now think about the 7 discretely-colored and brightness-controlled rows, and individual on/off control. When I think of brightness, my first approach is to use PWM. I think that technically this isn't the "right" way to do it, but I don't know how to make current sources, so PWM is the route I usually take. Let's assume that you have 7 outputs reserved and you are going with a 100% software solution, likely imprecise, i.e. you can't just set the PWM duty cycle in a register and automatically have the output toggle for you.

The next issue to look at is the 49 individual outputs for controlling each LED. It's a little crazy to try to source a micro with that many outputs just to do the LEDs, and impossible on an Arduino, so for this I recommend looking into serial-in, parallel-out shift registers. The last time I used one of these was for a scrolling LED matrix display in school, and it had 16 outputs. By now, maybe they have larger ones. But with 16 outputs, you only need 3 shift registers + 1 separate, or 4 shift registers, and one of them will only be connected to a single LED. Kind of a waste. Your software will be responsible for taking the pixels that you want to display, converting them into a serial stream, and then strobing the input to the shift register accordingly.

But what about the bi-color LED? You need two connections to each LED. At first, I though you could solve this with a simple logic circuit, so that turning a single output on or off results in a different color. But obviously, you want to also have a third state -- OFF. :) So basically, I think you can't get around having two "outputs" per LED.

Perhaps the best way to solve this is to then use two sets of shift registers -- one set of 3 (or 4) shift registers for one color, and another set for the other color. These shift registers need to have their parallel outputs set in synch, or you'll get some color mixing when both colors turn on simultaneously. I don't think this is going to be an issue, though. Just stream your serial data into both sets of shift registers first, then call one function that latches the bits (nearly) simultaneously. I think you'll also need extra buffer ICs or transistors for these extra outputs.

At this point, we have some ideas for solving the brightness control, color selection, and limited I/O capability of the Arduino, but we haven't tied it all together with an LED driver. LED drive capability can be handled by transistors, or a buffer IC that sources enough current. If you want to PWM above an LED's current rating (which I learned is acceptable within reason), then you'll probably have to go with discrete transistors, or maybe an IC like a ULN2003A. You only need one per brightness-controlled row. Again, PWM is controlled by the Arduino via a digital output and software.

So how does everything stick together? Well, I think the way I'd do it looks like this:

  • tie the outputs of all shift registers to one input of an OR gate
  • tie the PWM outputs to the other input of the OR gates. You'll have an OR gate per LED and color, so that's 98 OR gates, and you can find ICs with 4 gates per chip. That's still a lot of chips. Sorry, maybe someone else can suggest something better.
  • the output of the OR gates goes to the inputs of the buffer IC / transistors
  • the outputs of the buffers go to their respective LED legs

Phew. I know this isn't the most optimal solution, but hopefully some of the things I've brought up will help you out. I also hope that more experienced members here can comment on ways to make this approach better.

  • \$\begingroup\$ Hi Dave, thanks a lot for your elaborate answer, which contains a lot of useful info! It turns out that I actually do not need two-color LEDs, which changes the problem. I'll guess I better post a new question. \$\endgroup\$ – Andreas Aug 17 '11 at 1:46
  • \$\begingroup\$ See electronics.stackexchange.com/questions/18330/… \$\endgroup\$ – Andreas Aug 17 '11 at 1:57
  • \$\begingroup\$ I think you could have just edited this question so that it just lists one color as the requirement. :) \$\endgroup\$ – Dave Aug 17 '11 at 6:15
  • \$\begingroup\$ Oups...thought I couldn't edit the title. Also the relevant bits in your answer would have looked odd. \$\endgroup\$ – Andreas Aug 17 '11 at 8:00
  • \$\begingroup\$ @Andreas I would have simply edited my answer, no big deal. That's what we do here! :) Also don't forget to upvote reasonable / helpful answers. ;) \$\endgroup\$ – Dave Aug 17 '11 at 13:03

You could use "Neopixels" (WS2812) and shift out 49 sets of RGB pixel values.

Adafruit have detailed tutorial here: https://learn.adafruit.com/adafruit-neopixel-uberguide?embeds=allow&view=all

(Please note that I do not have any connection to Adafruit or Neopixels).

The Neopixels will handle the PWM for you. The 49 Neopixels would effectively form a long shift register and you will then only require 1 digital output pin to drive the whole lot.


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.