Max7219 and 8x8LED matrix - all LEDs are constantly on

Hello,
I am trying to put together a circuit using my arduino mega 1280, a max7219 LED driver and a 8x8 LED matrix.

I have torn down my circuit and rebuilt it. I have swapped every part and wire also. For some reason, my LED matrix lights up ALL the led’s all the time. Can someone help me understand what I’m doing wrong? Even if I set the intensity to 1 the brightness doesn’t change. Even if I indicate that only 1 LED should turn on, they still turn on. Even if I set lc.shutdown(0,true) they all stay on.

I have followed the wiring diagram here:
http://arduino.cc/playground/Main/MAX72XXHardware
C1 I have as 0.1uF
C2 I have as 100uF (not the 10uF as stated in the diagram but it’s all I have)
Rset is 10k

My code is:

#include "LedControl.h" //  need the library
LedControl lc=LedControl(12,11,10,1); // lc is our object
// pin 12 is connected to the MAX7219 pin 1
// pin 11 is connected to the CLK pin 13
// pin 10 is connected to LOAD pin 12
// 1 as we are only using 1 MAX7219
void setup()
{
  // the zero refers to the MAX7219 number, it is zero for 1 chip
  lc.shutdown(0,false);// turn off power saving, enables display
  lc.setIntensity(0,1);// sets brightness (0~15 possible values)
  lc.clearDisplay(0);// clear screen
}
void loop()
{
  for (int row=0; row<8; row++)
  {
    for (int col=0; col<8; col++)
    {
      lc.setLed(0,col,row,true); // turns on LED at col, row
      delay(10);
      lc.setLed(0,col,row,false); // turns off LED at col, row
      delay(10);     
    }
  }
}

Try this simple sketch. Uses the SPI pins to drive the MAX7219.
I had it running for 4 '7219s last night, stripped out the 2-3-4 digits here.
Connect pins 10,11,13 to the '7219. None of this silly software bit banging stuff.
D10 goes to Load (7219-12), D11 goes to DIN (7219-1), D13 goes to CLK (7219-13).
Make sure you have 0.1uF cap on its Vcc pin (7219-19), and an additional 10uF wouldn’t hurt.

/* program to put message on a MAX7219s.
 Set up in No Decode mode.
 */
// ************************************ //
//a_presetup
#include <SPI.h>

// define pins usage
// D11-12-13 SPI interface

byte ss0 = 10;
byte x;
// define variables
// bytes to send to MAX7219s, with some initial data
byte displayArray[] = {
  0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0x55,0xaa,0x55,0xaa,0x55,0xaa,0x55,0xaa}; //16 bytes

// define 7219 register addresses for setup
byte decode_mode = 0x09; // 0x00 = No decode for digits 7-0
byte intensity_level = 0x0A; // 0x08 = mid level. Range is 0x00 to 0x0F
byte scan_limit = 0x0B; // 0x07 for all columns
byte shutdown_normal = 0x0C; // 0x00 - shutdown, 0x01 = normal
byte display_test = 0x0F; // 0x00 = normal, 0x01 = display test mode all on full

// ************************************ //

// b_setup
void setup(){

  pinMode (ss0, OUTPUT);
  digitalWrite (ss0, HIGH);

  Serial.begin(115200);

  // turn on SPI port
  SPI.begin();

  /*  set up MAX7219 registers  */

  // decode to No decode mode
  digitalWrite (ss0, LOW);
  SPI.transfer (decode_mode);
  SPI.transfer (0x00);
  digitalWrite (ss0, HIGH);

  Serial.println("No decode mode");

  // intensity to mid level
  digitalWrite (ss0, LOW);
  SPI.transfer (intensity_level);
  SPI.transfer (0x0f);
  digitalWrite (ss0, HIGH);

  Serial.println("Intensity");

  // scan limit to all 7 columns
  digitalWrite (ss0, LOW);
  SPI.transfer (scan_limit);
  SPI.transfer (0x07);
  digitalWrite (ss0, HIGH);

  Serial.println("Scan Limit");


  // dispay test On
  digitalWrite (ss0, LOW);
  SPI.transfer (display_test);
  SPI.transfer (0x01);
  digitalWrite (ss0, HIGH);
  delay(200);

  Serial.println("Display test on");

  // dispay test to normal
  digitalWrite (ss0, LOW);
  SPI.transfer (display_test);
  SPI.transfer (0x00);
  digitalWrite (ss0, HIGH);
  delay(200);

  Serial.println("Display test off");

  // shutdown to Normal mode
  digitalWrite (ss0, LOW);
  SPI.transfer (shutdown_normal);
  SPI.transfer (0x01);
  digitalWrite (ss0, HIGH);

  Serial.println("Normal mode");

  delay(250);

  Serial.println("setup done");

}
// ************************************ //

// c_loop
void loop(){

  // ************************************ //
  Serial.println("slaveSelect0 low "); // put data in registers 1 to 9. 16  bit transfer - address/data
  for (x = 1; x<9; x=x+1){
    digitalWrite (ss0, LOW);
    SPI.transfer (x);
    SPI.transfer(displayArray[x-1]);// array 0 to 7
    digitalWrite (ss0, HIGH);
  }

  delay(1000);

  Serial.println("slaveSelect0 high");

  for (x = 1; x<9; x=x+1){  
    digitalWrite (ss0, LOW);
    SPI.transfer (x);
    SPI.transfer(displayArray[x+7]); // array 8 t0 15
    digitalWrite (ss0, HIGH); 
  }

  delay(1000);

} // end loop

That code uploaded but it simply displayed all 64 LED's as on.

In fact when I even take out the arduino from the circuit completely all 64 LED's stay on...

Does it matter that much if I use a 100uF capacitor instead of a 10uF one?

10uF/100uF - either is okay.

Check your wiring - perhaps you have anodes/cathodes swapped.

That code will make the alternating LEDs turn on/off - I posted a video of it doing that yesterday for all 4 displays.

See video in this message. http://arduino.cc/forum/index.php/topic,126144.0.html

yumology: Hello, I am trying to put together a circuit using my arduino mega 1280, a max7219 LED driver and a 8x8 LED matrix.

I have torn down my circuit and rebuilt it. I have swapped every part and wire also. For some reason, my LED matrix lights up ALL the led's all the time. Can someone help me understand what I'm doing wrong? Even if I set the intensity to 1 the brightness doesn't change. Even if I indicate that only 1 LED should turn on, they still turn on. Even if I set lc.shutdown(0,true) they all stay on.

From the symptoms it sounds like you're putting the 7219 into "test" mode. Normally you'd have to do that deliberately but it could happen if you only ever put '1's on the data line (the test register is register 0x0f and you put '1's into it...)

SOLVED. Crossroads was right, I had my annodes and cathodes connected incorrectly. Thank you!

and didn't even see the schematic 8)

It must be psychic fault diagnosis 8) cool

Ok, new problem. Step 2 of my project is to control the bi-colors of my LED matrix. My schematic is attached.

I have proven that each MAX7219 is wired correctly by using the code from before to drive one and simply remove the other from the circuit by taking it out entirely. I see all LEDs light up perfect. The problem is when I have both MAX7219’s in at once none of my LEDs display.

Here is my code:

#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 12 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 */
LedControl lc=LedControl(12,11,10,2);
/* 
 This time we have more than one device. 
 But all of them have to be initialized 
 individually.
 */
void setup() {
  lc.shutdown(0,true);
  lc.shutdown(1,true);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
  lc.setIntensity(1,8);
  lc.clearDisplay(1);  
}

void loop() {     
  lc.shutdown(1,true);
  lc.shutdown(0,false);
  for (int row=0; row<8; row++)
  {
    for (int col=0; col<8; col++)
    {
      lc.setLed(0,col,row,true); // turns on LED at col, row
      delay(10);
      lc.setLed(0,col,row,false); // turns off LED at col, row
      delay(10); 
    } 
  }
  
  lc.shutdown(0,true);
  lc.shutdown(1,false);
  for (int col2=0; col2<8; col2++)
  {
    for (int row2=0; row2<8; row2++)
    {
      lc.setLed(1,col2,row2,true); // turns on LED at col, row
      delay(10);
      lc.setLed(1,col2,row2,false); // turns off LED at col, row
      delay(10);
    }
  }
 
}

You need to use 7221's then:

"Eight-Digit Drive Lines that sink current from the display common cathode. The MAX7219 pulls the digit outputs to V+ when turned off. The MAX7221’s digit drivers are high-impedance when turned off."

"Seven Segment Drives and Decimal Point Drive that source current to the display. On the MAX7219, when a segment driver is turned off it is pulled to GND. The MAX7221 segment drivers are high-impedance when turned off."

LOL, I waited a month for these stinking 7219's to come in. Ok thanks for the help once again!

A month? Where'd you order from? I got 8 in less than a week from taydaelectronics. $1.25 each. I have red/green displays (freebies) that I thought were single color, didn't really have plans for dual color so am using just 1 for now. No thoughts as to content for dual color yet.

Ordered on ebay and it just took a month for some reason. Thanks for the link.

See here is where I went wrong. I saw this video http://www.youtube.com/watch?v=GPokkuX_jjk&t=4m12s Right at the 4m 12s mark you see the schematic which I guess just can't work.

I wonder if it has has anything to do with a common anode LED matrix compared to a common cathode...

You have common anode parts? Bet it could still be made to work. I see he has the 2 parts daisy chained, and sharing the cathode. Don't see how that's working with the multiplexing. Like to see the code behind it.

I just checked my matrix.

Pin 1 is held at positive. If I then put Pin12 at negative a green LED turns on. Or if I put Pin13 at negative a red LED turns on.

To me this means I must have a common anode matrix.

Perhaps - do you have a part number? Just about anything can be found on the internet.

This is what mine looks like. CSM-8826 is on the artwork it the back. Side is marked A5880SRSG-A, which seems incorrect - other A5880 parts I could find are only 16 pin parts.
I think I need to re-do my fonts to turn them 90 degrees for this part.
And do a little experimenting, see where “upper left” vs “lower right” is so the fonts make sense.

I defined an 8x32 array to represent the display, not sure I have that lined up with my chip callouts from left to right either.
So for example if I call 0,0 the lower left, 7,0 the upper left and 0, 31 the lower right and 7,31 the upper right, I’m not sure I’m send stuff there now.
Maybe I should flip it 31,7 for upper left and 0,0 for lower right - probably easier to visualize and keep straight that way.
Then call 3 the left display and go across 2-1-0 to the right.

Was just glad to show the hardware all worked to start - having left off +5/Gnd to 3 chips had me stumped for a bit :cold_sweat:

CSM88261_red_green_8x8.pdf (266 KB)

I built my own mini LED matrix. One with a common anode and one with common cathode. The common cathode works brilliantly, the common anode, well I can’t get it to work at all. Attached is the schematic for what works and doesn’t.
So it looks like I can get either a new set of LED matrix’s or the 7221’s. I can’t think of a way to get this to work any other way…

yumology: I built my own mini LED matrix. One with a common anode and one with common cathode. The common cathode works brilliantly, the common anode, well I can't get it to work at all. Attached is the schematic for what works and doesn't. So it looks like I can get either a new set of LED matrix's or the 7221's. I can't think of a way to get this to work any other way...

Any luck with your matrix? I have same problem with driving bicolor (common anode) matrix. But someone suggested to use a diodes on SEG A- SEG G lines...

I didn't realize you had common anode bratan. I was suggesting diodes for common cathode to prevent the max7219 from trying to source current into the cathode when it was put into shutdown mode.

Now that I think about it tho:

In common cathode, cathode goes to 7219 to prevent it from driving matrix cathodes high when in shutdown In common anode, anode goes to 7219 to prevent it from pulling matrix anode low when in shutdown

In both cases, the non-driving 7219 is isolated from the common pin so the other part can control the shared line.

I'll draw this up when I get home.

Dual MAX7219 controlling common cathode two-color array