Obvious errors?! MAX7219 8x32 led possibly malfunctioning

I’m in the middle of creating a point of sale display, part of it is a 8x32 led matrix (Max7219) which I hoped to have scrolling text on.

However no matter what examples from existing library’s I try, I just can’t get them to do pretty much anything!

I’ve attached some picture below, there seems to be 2 states, pictured below. I have also attached a photo of the set up on the Arduino mega, and here is the example code I used, which I haven’t edited.

If anyone can see any obvious problems, or can offer any advice, it would be greatly appreciated!

Code

<#include <LEDMatrixDriver.hpp>

// This sketch draw marquee text on your LED matrix using the hardware SPI driver Library by Bartosz Bielawski.
// Example written 16.06.2017 by Marko Oette, www.oette.info

// Define the ChipSelect pin for the led matrix (Dont use the SS or MISO pin of your Arduino!)
// Other pins are Arduino specific SPI pins (MOSI=DIN, SCK=CLK of the LEDMatrix) see https://www.arduino.cc/en/Reference/SPI
const uint8_t LEDMATRIX_CS_PIN = 9;

// Number of 8x8 segments you are connecting
const int LEDMATRIX_SEGMENTS = 4;
const int LEDMATRIX_WIDTH    = LEDMATRIX_SEGMENTS * 8;

// The LEDMatrixDriver class instance
LEDMatrixDriver lmd(LEDMATRIX_SEGMENTS, LEDMATRIX_CS_PIN);

// Marquee text
char text[] = "** LED MATRIX DEMO! ** (1234567890) ++ \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\" ++ <$%/=?'.@,> --";

// Marquee speed (lower nubmers = faster)
const int ANIM_DELAY = 30;

void setup() {
 // init the display
 lmd.setEnabled(true);
 lmd.setIntensity(2);   // 0 = low, 10 = high
}

int x=0, y=0;   // start top left

// This is the font definition. You can use http://gurgleapps.com/tools/matrix to create your own font or sprites.
// If you like the font feel free to use it. I created it myself and donate it to the public domain.
byte font[95][8] = { {0,0,0,0,0,0,0,0}, // SPACE
                    {0x10,0x18,0x18,0x18,0x18,0x00,0x18,0x18}, // EXCL
                    {0x28,0x28,0x08,0x00,0x00,0x00,0x00,0x00}, // QUOT
                    {0x00,0x0a,0x7f,0x14,0x28,0xfe,0x50,0x00}, // #
                    {0x10,0x38,0x54,0x70,0x1c,0x54,0x38,0x10}, // $
                    {0x00,0x60,0x66,0x08,0x10,0x66,0x06,0x00}, // %
                    {0,0,0,0,0,0,0,0}, // &
                    {0x00,0x10,0x18,0x18,0x08,0x00,0x00,0x00}, // '
                    {0x02,0x04,0x08,0x08,0x08,0x08,0x08,0x04}, // (
                    {0x40,0x20,0x10,0x10,0x10,0x10,0x10,0x20}, // )
                    {0x00,0x10,0x54,0x38,0x10,0x38,0x54,0x10}, // *
                    {0x00,0x08,0x08,0x08,0x7f,0x08,0x08,0x08}, // +
                    {0x00,0x00,0x00,0x00,0x00,0x18,0x18,0x08}, // COMMA
                    {0x00,0x00,0x00,0x00,0x7e,0x00,0x00,0x00}, // -
                    {0x00,0x00,0x00,0x00,0x00,0x00,0x06,0x06}, // DOT
                    {0x00,0x04,0x04,0x08,0x10,0x20,0x40,0x40}, // /
                    {0x00,0x38,0x44,0x4c,0x54,0x64,0x44,0x38}, // 0
                    {0x04,0x0c,0x14,0x24,0x04,0x04,0x04,0x04}, // 1
                    {0x00,0x30,0x48,0x04,0x04,0x38,0x40,0x7c}, // 2
                    {0x00,0x38,0x04,0x04,0x18,0x04,0x44,0x38}, // 3
                    {0x00,0x04,0x0c,0x14,0x24,0x7e,0x04,0x04}, // 4
                    {0x00,0x7c,0x40,0x40,0x78,0x04,0x04,0x38}, // 5
                    {0x00,0x38,0x40,0x40,0x78,0x44,0x44,0x38}, // 6
                    {0x00,0x7c,0x04,0x04,0x08,0x08,0x10,0x10}, // 7
                    {0x00,0x3c,0x44,0x44,0x38,0x44,0x44,0x78}, // 8
                    {0x00,0x38,0x44,0x44,0x3c,0x04,0x04,0x78}, // 9
                    {0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x00}, // :
                    {0x00,0x18,0x18,0x00,0x00,0x18,0x18,0x08}, // ;
                    {0x00,0x10,0x20,0x40,0x80,0x40,0x20,0x10}, // <
                    {0x00,0x00,0x7e,0x00,0x00,0xfc,0x00,0x00}, // =
                    {0x00,0x08,0x04,0x02,0x01,0x02,0x04,0x08}, // >
                    {0x00,0x38,0x44,0x04,0x08,0x10,0x00,0x10}, // ?
                    {0x00,0x30,0x48,0xba,0xba,0x84,0x78,0x00}, // @
                    {0x00,0x1c,0x22,0x42,0x42,0x7e,0x42,0x42}, // A
                    {0x00,0x78,0x44,0x44,0x78,0x44,0x44,0x7c}, // B
                    {0x00,0x3c,0x44,0x40,0x40,0x40,0x44,0x7c}, // C
                    {0x00,0x7c,0x42,0x42,0x42,0x42,0x44,0x78}, // D
                    {0x00,0x78,0x40,0x40,0x70,0x40,0x40,0x7c}, // E
                    {0x00,0x7c,0x40,0x40,0x78,0x40,0x40,0x40}, // F
                    {0x00,0x3c,0x40,0x40,0x5c,0x44,0x44,0x78}, // G
                    {0x00,0x42,0x42,0x42,0x7e,0x42,0x42,0x42}, // H
                    {0x00,0x7c,0x10,0x10,0x10,0x10,0x10,0x7e}, // I
                    {0x00,0x7e,0x02,0x02,0x02,0x02,0x04,0x38}, // J
                    {0x00,0x44,0x48,0x50,0x60,0x50,0x48,0x44}, // K
                    {0x00,0x40,0x40,0x40,0x40,0x40,0x40,0x7c}, // L
                    {0x00,0x82,0xc6,0xaa,0x92,0x82,0x82,0x82}, // M
                    {0x00,0x42,0x42,0x62,0x52,0x4a,0x46,0x42}, // N
                    {0x00,0x3c,0x42,0x42,0x42,0x42,0x44,0x38}, // O
                    {0x00,0x78,0x44,0x44,0x48,0x70,0x40,0x40}, // P
                    {0x00,0x3c,0x42,0x42,0x52,0x4a,0x44,0x3a}, // Q
                    {0x00,0x78,0x44,0x44,0x78,0x50,0x48,0x44}, // R
                    {0x00,0x38,0x40,0x40,0x38,0x04,0x04,0x78}, // S
                    {0x00,0x7e,0x90,0x10,0x10,0x10,0x10,0x10}, // T
                    {0x00,0x42,0x42,0x42,0x42,0x42,0x42,0x3e}, // U
                    {0x00,0x42,0x42,0x42,0x42,0x44,0x28,0x10}, // V
                    {0x80,0x82,0x82,0x92,0x92,0x92,0x94,0x78}, // W
                    {0x00,0x42,0x42,0x24,0x18,0x24,0x42,0x42}, // X
                    {0x00,0x44,0x44,0x28,0x10,0x10,0x10,0x10}, // Y
                    {0x00,0x7c,0x04,0x08,0x7c,0x20,0x40,0xfe}, // Z
                     // (the font does not contain any lower case letters. you can add your own.)
                 };    // {}, //


void loop()
{
// Draw the text to the current position
int len = strlen(text);
drawString(text, len, x, 0);
// In case you wonder why we don't have to call lmd.clear() in every loop: The font has a opaque (black) background...

// Toggle display of the new framebuffer
lmd.display();

// Wait to let the human read the display
delay(ANIM_DELAY);

// Advance to next coordinate
if( --x < len * -8 ) {
x = LEDMATRIX_WIDTH;
}
}
s

/**
* This function draws a string of the given length to the given position.
*/
void drawString(char* text, int len, int x, int y )
{
 for( int idx = 0; idx < len; idx ++ )
 {
   int c = text[idx] - 32;

   // stop if char is outside visible area
   if( x + idx * 8  > LEDMATRIX_WIDTH )
     return;

   // only draw if char is visible
   if( 8 + x + idx * 8 > 0 )
     drawSprite( font[c], x + idx * 8, y, 8, 8 );
 }
}

/**
* This draws a sprite to the given position using the width and height supplied (usually 8x8)
*/
void drawSprite( byte* sprite, int x, int y, int width, int height )
{
 // The mask is used to get the column bit from the sprite row
 byte mask = B10000000;

 for( int iy = 0; iy < height; iy++ )
 {
   for( int ix = 0; ix < width; ix++ )
   {
     lmd.setPixel(x + ix, y + iy, (bool)(sprite[iy] & mask ));

     // shift the mask by one pixel to the right
     mask = mask >> 1;
   }

   // reset column mask
   mask = B10000000;
 }
}/>

/>

VCC - 5v
GND - ground
DIN - 53 (MOSI)
CS - 9 
CLK - 52 (SCK)

https://www.minpic.de/i/8dv2/19vgtj
https://www.minpic.de/i/8dv1/1mgqli

Please read the forum instructions and modify your post to put your code in code tags.

Your images:

I've not seen that marquee library before so have absolutely no idea what the problem is.

We generally use Marco C's "Parola" library which you will find in the library manager in the Arduino IDE searching for "MD_MAX". You need to install MD_MAX72XX and MD_Parola. You will find plenty of examples of how to use them then installed.

Apologies I used < /> as opposed to will modify now.

I have also used the parola and MD_MAX library’s, also to no avail. I have also used the ledControl examples, and an array of others, however I’m yet to find a cause, or solution to the problem.

Couple of things to try:

  1. Have you tried to rotate the matrices by 180 degrees (try one and see if this fixes that one). You should not be damaging anything by doing this. They may have been plugged in incorrectly.
  2. Post a link to the place where you got the matrix (link to eBay or other place).
  3. What are the numbers on the side of the matrix device. There are 2 types and you may have been supplied with the wrong one)
  4. What controller are you using (MEGA?)? Does it make a difference if you are able to use a different controller? Or try different pins on the same controller?

Do you have those displays with 8x8 LED matrix modules plugged into 2 x 8-way sockets on small square PCBs ? It has been known that forum members have had these delivered by the (often eBay) supplier with the matrix module fitted the wrong way up on the PCB. Can you try removing & inverting one?

EDIT: Marco just beat me to the suggestion!

Thanks for all the ideas, i ordered a new one last night which arrived today, i do think it was a faulty matrix, as this one worked brilliantly... well did!

i managed to get the 32x8 matrix, connected to another 8x8, giving me a 40x8, i programed it using the suggested parola library, then all of a sudden, all the led lit, and stayed lit, since this it almost seems unresponsive.

another thing thats just become apparent is that the computer will not recognise the arduino (uno or mega) when the matrix is wired into the board, but as soon as i unplug the matrix, i hear the chime to say the computer has recognised it

Sounds like you are overloading the power supply. You cannot power all those matrices from the Arduino power supply and will need to connect an external supply providing about 2 amps to cover the load. Remember to join all the ground lines together to make sure it works.

SamJW:
Thanks for all the ideas, I ordered a new one last night which arrived today,

That would have cost a bit!

Did you try turning the displays around or are they soldered in?

SamJW:
another thing that's just become apparent is that the computer will not recognise the Arduino (UNO or mega) when the matrix is wired into the board, but as soon as I unplug the matrix, i hear the chime to say the computer has recognised it

That will be because you need a 5 V power supply with sufficient current capability to drive the matrix. Suspect you were attempting to power the matrix from the "5V" terminal on the Arduino.


Looking more closely at your original photos. You refer to two "states". Are you saying that one particular display was alternating between these two states, or that you have two displays each of which shows a certain pattern?

An interesting test is to take the display and power it up from 5 V (of course) with data and clock grounded, latch connected to 5 V before you power it up? A working display will power up blank. In fact, you should have a 22k pull-up resistor on the latch line in any working system to ensure it starts up blank rather than with a flash. (Or is that a pull down? It depends on how the code initialises. It actually should not matter much.)


Oh yes, what is the part number on the side of each matrix - of the working and the non-working units? And is it on the same side?

marco_c:
Sounds like you are overloading the power supply. You cannot power all those matrices from the Arduino power supply and will need to connect an external supply providing about 2 amps to cover the load. Remember to join all the ground lines together to make sure it works.

Thank you, I planned to have a separate power supply, I thought I’d get away with powering it from the board whilst I was testing it, and sorting the code. Could this have caused lasting problems? Thanks again

Should not have. The power supply browns out and the cpu resets. This then initialized the display to blank again and off it goes. The sound you hear on the pc is the USB port being disconnected and then reconnected during the power cycle.