First off, neither an Arduino's GPIO pins (as Kurt E. Clothier has pointed out), nor more relevantly the voltage regulators on board any standard Arduino board, can supply the amount of current required to operate 42 LEDs simultaneously:
42 x 20 = 840 mA
is well beyond the typical 500 mA polyfuse on the Arduino's vUSB power rail. You would not actually come up against the microcontroller's own current limitations, since the LEDs are most likely not going to be driven directly by the GPIO pins, but by the shift registers mentioned in the question.
While the regulator on the board may be rated for 1 Ampere or more on some Arduino clone boards (the Ruggeduino comes to mind), drawing that much current will cause the regulator to overheat, and either shut down due to thermal protection, or get damaged.
On the other hand, given the bill of materials in the question, it seems a safe assumption that no more than one row of 7 LEDs is to be lit at a given time, in a multiplexed matrix arrangement. 7 x 20 = 140 mA
is well within the capabilities of the typical Arduino board's regulator.
Consider replacing the 74HC595 shift registers with the Texas Instruments TPIC6A595 shift registers, which support 350 mA per output pin, and thus eliminate the need for the drive transistors. There are other slightly lower specification and lower cost shift registers as well, with high current rating and low output resistance, including the TPIC6C595 (100 mA per channel), if price is a factor.
The reason for this suggestion is not just cost saving on the (inexpensive) drive transistors, but the reduction of design complexity, and elimination of possible errors in wiring up that many additional components.
Since each LED is dropping 1.8V, then there will be about 3.2V dropped across each 330 ohm resistor -> 5V - 1.8V = 3.2V.
The current through the resistor is the same as the current through the LED in series. This is calculated as resistor voltage divided by resistance -> 3.2V / 330 ohms = 9.7mA. This is the current through each LED string consisting of one series resistor and LED.
There are 16 LEDs, but using this style of matrix multiplexing, a maximum of 4 should ever be on at one time. That means your maximum current consumption should be found by multiplying the current through one LED string by the total number of strings -> 4 * 9.7mA = 38.8mA.
Power (watts) is simply voltage multiplied by current:
- Total Power: 5V * 38.8mA = 194mW
- Power Per LED String: 5V * 9.7mA = 48.5mW
- Total LED Power: 1.8V * 38.8mA = 69.84mW
- Total Resistor Power: 3.2V * 38.8mA = 124.16mW
- Efficiency: 69.84mW / 194mW * 100% = 36%
The efficiency is very low because so much voltage is dropped across the series resistors. Since you only need one LED at each matrix point, the best way to increase the efficiency would be to use a lower voltage power supply. For example, if the supply was 3.3V instead of 5V, only 1.5V would be dropped across each resistor. To maintain the same 10mA through each LED, the resistor size would be changed from 330 ohms to 150 ohms (1.5V / 10mA). With less voltage dropped across each resistor with the same amount of current flowing, less power is wasted in the resistors. The new numbers would look like this:
- Total Power: 3.3V * 40mA = 132mW
- Power Per LED String: 3.3V * 10mA = 33mW
- Total LED Power: 1.8V * 40mA = 72mW
- Total Resistor Power: 1.5V * 40mA = 60mW
- Efficiency: 72mW / 132mW * 100% = 55%
When driving LEDs in this manner, you want the total supply voltage to be as close as possible to the total LED string voltage (one LED or a few LEDs in series) with a bit extra to drop across a series resistor to set the current. If you could use a 2.0V supply, 20 ohm resistors would drop 0.2V for the same 10mA. This would drop the total power consumption to 80mW and increases the efficiency to 90%!
Of course, you would probably have to use a voltage regulator to achieve this irregular voltage supply level which will lower the efficiency (matrix efficiency * regulator efficiency). You'd really need to use a switching regulator which could have greater than 90% regulation efficiency. If you use a linear regulator, it will yield the same low efficiency in the end because it is burning off the extra voltage as heat, similar to the series resistor in your original design.
If you are using multiple LEDs at each matrix point, put as many in series as possible (in your case, 2 is all you can do with a 5V supply and 1.8V LED) rather than in parallel to save on wasted current.
You didn't ask this in the question, but keep in mind that when multiplexing LEDs in this manner, each will only be on 1/4 of the time because you are using an Nx4 matrix. Hence, the LEDs will only appear to be about 1/4 as bright as they would be when driven continuously with the same series resistance (again, not exactly due to the nonlinear light output to current relationship).
Best Answer
I assume that that the cable shown in your second picture will plug into the white connector on the back of your LED matrix. If so, I would cut off one connector, and connect the two red wires to the positive terminal of the barrel connector-to-terminal block adapter, and the two black wires to the negative terminal of that terminal block.