## ASK AN EDUCATOR! “How do I choose resistors to match a multiplexed led matrix?”

How do I choose resistors to match a multiplexed led matrix?

Great question and the answer is a little elusive. Let’s at the diagram for Adafruit’s 8×8 matrix:

As you might know, there are many ways to drive a LED Matrix, and we will assume you have an 8×8. The easiest is to drive it directly from your microcontroller using 8 pins for the anodes and 8 for the cathode. With this configuration you can individually control all 64 LEDs and have a variety of methods for switching them on and off. If you look at the I/O capability of your microcontroller you will notice that they are only capable of sinking ~30-40mA per pin. If you were to were to illuminate an entire row with a common cathode, you would draw ~160mA and blow out your controller.

First the math:

If you look at the spec sheet for Adafruit’s matrix, the LEDs have a Vf of 2.2V and draw 25mA. In order to properly illuminate them with a 5V supply you would need a 112ohm (120ohm is the closest without going below) resistor. R = (5V – 2.2V) / 0.025A = 112ohm.

The problem with using a 120ohm resistor in series with the anode of each column is that when you illuminate more then one row at a time, the current available for each LED decreases…so you will get an uneven illumination of the panel.

If you run the calculation for 8 LEDs in parallel, you would need 14ohm (15ohm is the closest without going over) resistors to deliver 25mA to each LED. The problem with this is that the voltage is going to increase across each diode when less then 8 are illuminated, and you would be drawing 200mA! Far more then your microcontroller can handle.

This brings us to our control theory:

Method 1:
Since you are multiplexing the LEDs you can take advantage your processors high speed by “scanning” the grid. With just your microcontroller, you can illuminate each LED with a 60hz refresh rate so you eyes dont see the flicker. You could implement an algorithm to scan from the top left to bottom right (just like a CRT). This would allow you to run an entire panel with relatively low current draw. Arduino.cc has a good overview, although they are not using the scan method, and don’t forget the dropping resistors.

Method 2:
You can use your microcontroller to control more then one row at a time by controlling the anodes and cathodes with MOSFETs. This would allow for you to run your panel at even higher current ratings then the “constant on” current from the data sheet. You can change the duty-cycle controlling the rows to allow for ~100mA per diode. You will get a much higher brightness, and if you cycle them at >60hz, you eyes wont really notice the flicker. Here is a good example using 2n3906 and 2n2222 transistors.

Method 3:
You can also accommodate for the high current loads through the matrix by using a stand alone multiplexer. The IC allows you to isolate your microcontroller and allow you to take greater advantage of multiplexing by controlling more then one row at a time. Arduino.cc has a list of tutorials as well for setting up a matrix using drivers.

Don’t forget, everyone is invited to ask a question!

“Ask an Educator” questions are answered by Adam Kemp, a high school teacher who has been teaching courses in Energy Systems, Systems Engineering, Robotics and Prototyping since 2005.

Related
Filed under: educators — by akemp, posted June 22, 2012 at 8:41 am

Try Adafruit's new iPhone & iPad app for makers! Circuit Playground! "Incredibly handy for anyone working in electronics. Perfect for engineers and non-engineers alike."
Looking for engineers, makers and the builders of dreams? Try our Adafruit job boards.

## 1 Comment

1. Thanks, this was extremely helpful in understanding an issue I have been running into.

Comment by levi366 — June 22, 2012 @ 11:48 am