I am trying to do my first Arduino project, and I would like to drive a 5x5 matrix of IR leds. I would only like to have one switched on at a time.

I understand that in an array I can do it with 5 lines for anodes and 5 lines for cathodes. My problem is that I cannot supply 100 mA with an Arduino.

What would be the easiest way for me to supply 100 mA for these leds? I think they don't need current limiting, if I could drive them with 1.35 V voltage, it would work perfectly. I've measured a couple of my LEDs and they used exactly 100 mA at 1.35V.

I know that I can use a transistor for supplying a higher current power source, but I don't understand that how could I do it with a 5x5 LED matrix. How many transistors do I need? 5 or 10? And if I need 10 transistors, then I understand the 5 which supply 1.35 V, but what are the other 5 doing? How can a transistor supply 0 V?

Or, as an ugly trick, I was thinking about using a Mega, and for each line, using 3 pins in parallel. I mean one pin has a current limit of 40 mA, so 3 pins would be enough for 100 mA. That way I wouldn't need to care about an other power source, and transistors. I could just run the whole thing from USB. All I would need would be 5 resistors. Is that a good option?

Or, as an alternative, I was thinking about using Rainbowduino in itself. It has current limiting, and in theory I could possibly run the whole thing from 5V USB. But it seems really complicated to just control 5x5 LEDs. I don't understand the whole idea about source driving the anode and current driving the cathode! Isn't it a circuit, I mean we either set the source, or the current? And why does the anode has 500 mA current limit, while the cathode has 120 mA? So while it looks good on paper, I think I'm really not on a level to understand how it works.

All I would need is to control 5x5 LEDs, where each of them would require 100 mA @ 1.35 V. What would be the best way you’d recommend me doing it?


3 Answers 3


First, a safety warning

25 IR LEDs at 100 mA each will be a LOT of IR radiation. If they're close together, your pupils are dilated (indoors, this is often true), and/or you're close to the matrix, you could really hurt your eyes.

The image of the matrix will be focused to a tiny area on your retina, and you'll hear/feel a little pop as the blood and fluid there boils. You'll have a permanent blind spot. Not fun. BTW, it's your job to make sure that you understand what you're doing and don't hurt yourself, not mine. I'll help you begin understanding, but I won't be held responsible.

My advice: For development (and production if possible), put bright green LEDs in series and physically close to the IR LEDs so that your blink reflex is activated at a bare minimum. Use hardware (in addition to software) techniques to limit the number of LEDs lit and/or the power delivered to the matrix to help ensure that only one LED is on at a time.


There are many LED driving techniques. None of them hinge on delivering 1.35V; that will change between LED batches, over time, and with temperature.

If you're just interested in current limiting, a few transistors will be sufficient. The total transistor count will depend on your choice of a current limiting circuit topology, which is dependent on your heat sinking capabilities, routing area, and other contstraints. There are also voltage/current regulation ICs and linear LED drivers which would simplify your job. If you're interested in power conservation, many buck converters can be configured for current limiting, which would maximize your battery life.

You may want to have unlimited sink and limited source (or vice versa). Alternatively, you might have just one current source, and mux it between the various LEDs. Because of the safety issues inherent in this project, I'd recommend the latter option.


How did you measure the led current? An led will act as a diode while in forward conduction and will take as much current as you can supply, or will destruct at its current limit. Sounds as if your 1.35 volt supply might have been limited to 100ma. Also if they are IR led's does your circuit need to pulse modulate them?

In any case, you could use a current limiter on the high side which could be anything from a single resistor (only one led on at a time) to a current regulator. See LM317 datasheet for how to make a current limiter with only one resistor. You will need 10 switching devices. Five to switch the high side (positive) and five to switch the low side (negative).

  • \$\begingroup\$ I have used a pot as a current limiting resistor and I've measured the current at various voltages between 1.3 to 1.4 V. When I supplied it with 1.35 V the current through the circuit was 100 mA. It won't need any modulation, I just want to switch them on and off in the seconds range. \$\endgroup\$
    – hyperknot
    Mar 29, 2011 at 21:11
  • \$\begingroup\$ It's hard to say if you found the correct drive current by doing that. You could be overdriving (or under-driving) the led. Please use the precautions that reemrevnivek has point out. Your method is fine for determining a standard led that you can see the brightness as you reach the target current, however you would need to measure the IR radiation some how to see if you are driving an IR led efficiently. I assume there is no datasheet available. Perhaps you can find a similar IR led datasheet of the same package and make some assumptions. \$\endgroup\$
    – SteveR
    Mar 30, 2011 at 11:46
  • \$\begingroup\$ Oh, there are loads of datasheets available, its from Vishay: vishay.com/ir-emitting-diodes/list/product-81011 \$\endgroup\$
    – hyperknot
    Mar 31, 2011 at 9:39

First, I make a note that you only want one LED on at a time. (I don't have the foggiest why you would do this, however, given that they're IR.)

Let's start with a simpler situation: suppose you would only need 1mA. Then you could use a 74HC238 to drive the 5 rows. The 74HC238 is a demultiplexer with 1 output out of 8 high. Use a 74HC138 to drive the 5 columns. It's a similar device but with the active output low. (I'm following my own convention that rows source current, columns sink.) So you would place the LEDs with the anodes connected to the rows, and the cathodes to the columns, and place a current limiting resistor in each row.

Now neither the 74HC138 nor the 74HC238 can drive a 100mA LED directly, so we'll need transistors to increase the current.
Let's start with the 74HC238. This has an active high output, which will become active low if we drive an NPN transistor with it via a base resistor (the transistor works as an inverter). Likewise, the 74HC138 is active low, but when driving a PNP transistor this will become active high. Again, don't forget the base resistors. So the functions or rows and columns have switched, and the 74HC238 will drive the columns (sinking current), and the 74HC138 will drive the rows (sourcing current).

Never mind that the 100mA will give 1.35V forward voltage, do place the series resistors for the LEDs, either on the PNP's collectors or on the NPNs'. The internal resistance of a LED is too low to let it control the current if the voltage would deviate a little, for instance due to temperature changes.

Instead of the 5 NPN transistors you could use a ULN2803A if you want. This would save you the base resistors.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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