All LEDs stay on using Max7219?

Hi everybody,

I'm trying to use an Arduino Nano, a Max7219 IC and a 4-digit, 7-segment LED bar together, in order to be able to control individual LEDs later on. The 4-digit bar is just a test at the moment.



Following the datasheet and pinout of the digits as shown in the images above, I connected:

  • 5V from the Arduino to pins 18 (via a 10k resistor) and 19
  • ground from the Arduino to pins 4 and 9
  • pin 6 to DIN
  • pin 5 to CLK
  • pin 4 to LOAD
  • DIG0-DIG3 to COM1-COM4 of the digits
  • SEG A-SEG G / DP to A-G / DP of the digits

My code is as follows:

#include <LedControl.h>
LedControl lc = LedControl(6, 5, 4, 1);

void setup()
{
  Serial.begin(9600);
  
  lc.shutdown(0, false);
  lc.setIntensity(0, 4);
  lc.clearDisplay(0);

  for (int x = 0; x < 8; x++)
  {
    for (int y = 0; y < 8; y++)
    {
      lc.setLed(0, x, y, false);
    }
  }
}

void loop()
{
  for (int x = 0; x < 8; x++)
  {
    Serial.println(x);
    for (int y = 0; y < 8; y++)
    {
      lc.setLed(0, x, y, true);
      delay(500);
      lc.setLed(0, x, y, false);
      delay(500);
    }
  }

  Serial.println("Repeat");
}

When I run this, I can see in the serial monitor that the loop gets processed, but all LED segments always stay lit.

Changing the intensity didn't help, nor did changing the pins 6, 5, 4 to other pins (12, 11, 10, etc...).

When I had a look at the segments with my scope, each segment always appears to receive about 3V, but gets a spike of 5V when it is triggered in code. Before I had a few individual LEDS, this situation was the same.

I've tried two MAX7219 ICs, both acted the same. Both are from the same batch from Banggood. In the past I got this to work, with an IC from a local shop, but that one is built into a project so I can't try that one.

Also, I realise that the IC is a common-cathode driver and that the digit bar is a common-anode one, but this only swaps columns and rows, which is not a problem in my case. I'm trying to control individual LEDs, not digits.

Does anybody have any idea what's going on here? Any info would be greatly appreciated!

Thanks in advance!

Marlon

Hello everybody,

Never mind, I just figured it out...

Since the digits are common-anode instead of common-cathod, DIG0-DIG7 need to be swapped with the SEG outputs of the IC, of course.

D'oh!

Anyway I though I'd post a reply myself should anyone else face the same problem later on.

Marlon

This is a common mistake, especially with 8x8 led matrix, where it's easy to fit the matrix to the PCB upside down, which results in the same issue because the anodes and cathodes are swapped. Sometimes they arrive fitted incorrectly like this from the manufacturer/supplier!