I'm currently trying to learn how multi shifting is working and have therefore started a project where I wanna drive 2X 8x8 LED matrix with an Arduino. I have found it that I should work with the 74HC595 chip.

This is the schematic I'm using to try out how the chip works.

Scematic over 8x8

But when I use this with the following code, it doesn't light every LED up and some of them are less bright than the rest.

#define DATA 10
#define CLOCK 11
#define LATCH 12

void latch();
uint8_t pic[] = {250,250,250,250,250,250,250,250};

void setup() {
  pinMode(DATA, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(LATCH, OUTPUT);

void loop() {
  for (int i=0; i<8; i++) {
    shiftOut(DATA, CLOCK, LSBFIRST, ~pic[i]);
    shiftOut(DATA, CLOCK, LSBFIRST, 128 >> i);


void latch() {
  digitalWrite(LATCH, HIGH);
  digitalWrite(LATCH, LOW);

8x8 LED matrix Error Light

What can cause that? Do I have bad wiring? or bad code?


I have tested my LED matrix with the code from @vicatcu. First I found a lot of bad connections they are now fixed, I hope..

Now I have found 2 full columns, 1 full row and a couple of other LED's that don't light up, the middle row where there are 3 LED's that don't light up is light up when I set everything to 0 instead of 250.

LED matrix 2.0

If I remove the "~" from the code then I get this:

LED'matrix removed ~

Update 2

I tried @James idea and moved the resistors from the columns to the rows, but that didn't fixe the problem rather it just moved some of the on light pixels Scematic over 8x8 2.0

8x8 LED matrix Error Light 2.0

  • \$\begingroup\$ Get out the DVM and measure the voltage in the unlit ones, compare and contrast to the working ones. \$\endgroup\$
    – Tyler
    Commented Jan 5, 2020 at 17:00

5 Answers 5


The 74HC595 powered at 4.5 volts when driving a load current of 6 mA will produce an output voltage of somewhat less than 4.5 volts; more like 4.3 volts (Table 7.5 in the electrical characteristics). This is a typical value and it may be as low as 3.98 volts.

You are trying to drive up to 8 LEDs simultaneously from one row output. You might be aiming for 10 mA per LED. I say this because a typical LED drops nominally 2 volts and an extra diode drop of 0.7 volts (matrix diodes) means there might be 2.3 volts left across each 220 ohm column resistor. So, 10 mA is my estimate and, if you want 8 LEDs activated that, a current of 80 mA.

Well firstly, the HC595 cannot be hoped to supply that sort of current. If you look at the absolute maximum ratings in the data sheet is says 35 mA per output pin so, your expectations are far exceeding your hardware.

And this causes the problem you see because it erodes at the output voltage to such a degree that the current delivered to each LED becomes "variable". A batch of LEDs might indicate that the average volt drop at 10 mA is 2.00 volts but, the range of volt drops might be from 1.9 volts to 2.1 volts.

If you did the math on those extremes when the HC595 is only outputting (say) 3.5 volts (because of extortionate over demand), you would find that the current into an LED that works happily on 1.9 volts is 4.1 mA whereas the current delivered into an LED that needs 2.1 volts is 3.2 mA.

That's what produces brightness inconsistencies.


Separate from other aspects mentioned before, there is one simple fault:

Writing decimal 250 to the shift register will only turn on 6 of the 8 bits because 250d = 0xFA = 1111 1010 binary. 255 is the correct decimal number.

Sink capability of the HC595 is a bit better than source, so there is a little advantage in swapping the shift register functions and invert the logic as in the answer from @vicatu :

  1. shiftOut(DATA, CLOCK, LSBFIRST, ~(128 >> i));
  2. shiftOut(DATA, CLOCK, LSBFIRST, pic[i]);

This way it is better to have the resistors in the anode path for a more equalized current distribution. 220 ohm is too low anyway.

There are power versions of this shift register, which can provide much more sink current for the cathode side, e.g. STPIC6C595, NPIC6C595, TPIC6C595. They can not be used for the anode side.


Lets analyze what's going on here. The code is implementing a multiplexing scheme, which is to say at any given moment, only one row of LEDs is being "addressed" (i.e. 128 >> i, the row addressed by the i-th bit). I'd advise you to rename the variable called SHIFT to CLOCK as that is what most people will expect it to be called. Usually the variable you call STORE is called LATCH. You should declare int pic[] as uint8_t pic[] instead so it's the right size (8-bits instead of 16-bits) for what you are trying to express as well.

All of that said, I don't think any of it explains the outcome in the picture. I think it's more likely a wiring error of some kind or an power issue. Can the 74HC595 source / sink 100mA? Because that is what you are asking of it with 8 LEDs, a 5V power source, and 220 Ohm resistor.

I would start with a much more simple sketch that allows you to stimulate each pixel of the matrix individually, and in a way that is under your control through the serial terminal, for example. Something like this:

#include <stdint.h>

#define DATA 10
#define SHIFT 11
#define STORE 12

uint8_t row = 0, col = 0;

void store();

void setup() {
  Serial.println("Test One LED at a time");
  pinMode(DATA, OUTPUT);
  pinMode(SHIFT, OUTPUT);
  pinMode(STORE, OUTPUT);

  // initialize the shift registers
  shiftOut(DATA, SHIFT, LSBFIRST, 0);
  shiftOut(DATA, SHIFT, LSBFIRST, 0);   


void loop() {
  if (Serial.available()) {
    Serial.print("Lighting row "); Serial.print(row);
    Serial.print(" and column "); Serial.println(col);

    uint8_t rowval = (1 << row);
    uint8_t colval  = ~(1 << col);
    shiftOut(DATA, SHIFT, LSBFIRST, colval);
    shiftOut(DATA, SHIFT, LSBFIRST, rowval);   

    if (col > 7) {
      col = 0;
      if (row > 7) {
        row = 0;

void store() {
  digitalWrite(STORE, HIGH);
  digitalWrite(STORE, LOW);

And just see if you can get each LED to light up one at a time. Make sure you configure the Serial Monitor to have "no line ending" and for every character you send, the LED will advance by one position in row major order. At startup, no LEDs should be illuminated.

  • 1
    \$\begingroup\$ Okay, thanks, I have created an update \$\endgroup\$ Commented Jan 7, 2020 at 15:53

Let's analyze the problem which is all due to wrong drivers for proper impedance. (mis-wiring and failed IC wirebonds maybe from over heating)

The 74HCxx driver resistance is too high. For proof of concept increase all 220 Ohm resistors to say 0.5~1k Ohm and tolerate low illuminant intensity.

They give driver specs with -10% Vcc tolerance like 4.5V and 6V

Let's consider worst case at 4.5V because Ron rises in CMOS as they get hot.

Zol = Vol(max)/Io= 0.4V/6mA = 67 Ohms ; Zoh = -0.8V/-6mA= 133 Ohms

Each LED will have an effective series resistance that depends on current around 10 Ohms

Thus the total current is (5V-2.1)/ (67+133+(1~10?) = 20 mA

The ones with no light are defective wiring or IC's too hot.

They do make proper IC's for Matrix driving.

  • \$\begingroup\$ The OP's got 220 Ohm resistors on each column drive. At 5V (which I assume he's using from Arduino) and 2.2V forward voltage, that's about 12.7 mA per output (i.e. [5 - 2.2] / 220). That being said, 100mA does exceed the rated continuous current through Vcc or GND which by my read of the datasheet is 70mA. If the OP bumps the 220 Ohm resistors up to 330 Ohms that would put a full column illumination within spec. \$\endgroup\$
    – vicatcu
    Commented Jan 5, 2020 at 18:29
  • \$\begingroup\$ That 12.7mA describes only a single LED then 330R becomes <9mA or in theory x8 = 72 mA when all On. That's why I include driver for current estimates. Zout=Rol+Roh= 200 Ohms Obviously sensitivity to number of LED's active affects brightness even with 330 will be significant as current variation is 3.8V / Req and Req varies from 200 + 330 = 530 Ohms to 200+ 330/8(=42)=242 or a 2:1 variation in intensity while 1k would be more even but still poor. It can handle 350mW or 70mA but after the defects are fixed the brightness still varies 50% which I am sure you realize. FWIW @vicatcu \$\endgroup\$ Commented Jan 5, 2020 at 18:48
  • \$\begingroup\$ As vicatcy writes, there are 220-ohm resistors on each column and yea I'm using an Arduino to run it all, which after my knowledge should be more than enough to this project. None of the 2 chips is getting warm \$\endgroup\$ Commented Jan 7, 2020 at 16:14
  • \$\begingroup\$ Ok Marc check again when all LEDs are ON \$\endgroup\$ Commented Jan 7, 2020 at 17:15
  • \$\begingroup\$ Well the problem is that I cant get them to light up, some of the rows and columns won't light up \$\endgroup\$ Commented Jan 8, 2020 at 14:24

You've got the resistors in the cathode circuit. The resistors should go the other side of the LEDs in the anode circuit.

At the moment you are driving each column of 8 leds with a shared dropper resistor and forcing all 8 to have the same forward voltage drop. This causes current hogging and can blow some of the LEDs.

  • \$\begingroup\$ I have let me hear that I could more or less just put the resistors where ever I wanted around the LED's? But I can just fix my problems by changing the place of the resistors? \$\endgroup\$ Commented Jan 7, 2020 at 16:25
  • \$\begingroup\$ Move the resistors to between U2 and the LEDs. \$\endgroup\$
    – user173271
    Commented Jan 7, 2020 at 16:32
  • \$\begingroup\$ Okay I will try that :) \$\endgroup\$ Commented Jan 7, 2020 at 16:35
  • \$\begingroup\$ Now the 3. and 5. row and the 6. and 7. column doesn't light up? \$\endgroup\$ Commented Jan 8, 2020 at 13:54

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.