Max7219 module mirroring

Hey there everyone, this is my first time posting and I am a newbie when it comes to electronics so I apologize if some of this does not make sense.

I am using a Photon 2 to power 3 daisy-chained MAX7219 4in1 8x8 modules. I am hoping to display live sports scores on it using a webhook I've set up with a web server.

Using the LedControl-MAX7219-MAX7221.h library, I was able to daisy-chain two of these modules together no problem, however once I soldered the third on I began running into my problem. Essentially, the third module (right-most) replicates whatever information the first module is displaying at all times (I will add a photo for reference).

Here is my code:

#include <LedControl-MAX7219-MAX7221.h>

// Pins for LED matrix
const int DIN = D0; // Data In
const int CLK = D2; // Clock
const int CS = D1;  // Chip Select
const int NUM_MATRICES = 12; // Total number of matrices

LedControl lc = LedControl(DIN, CLK, CS, NUM_MATRICES);

void setup() {
    Serial.begin(9600);
  
    for (int matrix = 0; matrix < NUM_MATRICES; matrix++) {
        lc.shutdown(matrix, false);
        lc.setIntensity(matrix, 8);
        lc.clearDisplay(matrix);
    }
}

void loop() {
    const char* gameInfo = "PHX 80 v DEN 95 Q3 3:45 ";
    displayText(gameInfo);
    delay(10000); // Display each segment for 10 seconds
}

void displayText(const char* text) {
    int textLength = strlen(text); // Length of the text

    for (int i = 0; i < textLength; i++) {
        // Clear all displays before showing the next character
        for (int matrix = 0; matrix < NUM_MATRICES; matrix++) {
            lc.clearDisplay(matrix);
        }

        // Display text across the matrices
        for (int matrix = 0; matrix < NUM_MATRICES; matrix++) {
            int charIndex = i + matrix; // Index of the character in the text string
            if (charIndex < textLength) {
                for (int col = 0; col < 8; col++) {
                    byte character = text[charIndex];
                    byte columnData = cp437_font[character][7 - col]; // Correctly oriented
                    lc.setColumn(matrix, col, columnData);
                    Serial.print("Matrix: "); Serial.print(matrix);
                    Serial.print(", Char: "); Serial.print(character);
                    Serial.print(", Col: "); Serial.println(col);
                }
            }
        }
        delay(300); // Display this character for a short time before moving to the next
    }
}


and here is a photo of the issue:

I have tried debugging by sending unique information to both the first and third modules, but the third continues to mirror the first. I also looked through the library's documentation and it seems that it is capable of handling up to 8 of these modules.

Does anyone have any experience with this issue / ideas on how to fix it?

Thanks so much in advance!!

I have used a bunch of these displays, mostly bought from the China-based suppliers.

  1. These are +5V devices so your Photon 2 needs a level shifter. Yes the 3.3V output of the Photon 2 should be enough, but in my experience you will need to level-shift to get reliable operation.

  2. These displays can draw a lot of current. I can drive one four-digit 8x8 display using the +5V USB supply but not two for instance, even when set to the lowest brightness.

Can you try a stand-alone +5V supply with decent current (more than 1A) to power the displays? The data and ground wires need to be tied to the Photon 2, but power can be separate.

I would also try to minimize the cable length between the Photon 2 and the first display. An inch or two is fine; 12 inches is too long.

1 Like

yes i have a 5v 2.4A battery pack with a USB power switch! would this be the correct wiring?

I just attempted with the configuration above ^. Unfortunately, the issue is still ocurring

@lhatakenaka, on top of what @bko said, looking at the LedControl library, you will find this line in the class constructor:

    if(numDevices<=0 || numDevices>8 )
	  numDevices=8;

It looks like the library limits the number of devices to 8 which explains why you are seeing the duplication on your third 4-in-1 unit (which would be devices 9 to 12). I have not found an arduino library that will do more modules yet.

2 Likes

oh I see! I interpreted that as 8 of the 4in1 modules. thank you for your help!

Hi @lhatakenaka -

On top of what @bko and @peekay123 said.... Sounds like your problem has been identified so all that remains I guess is... Welcome to the Particle forum!! :slight_smile:

Regards, Friedl.

4 Likes

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.