Problem with MAX7219

Hello!

I want to control my 4 digit 7-segment display, using my arduino nano, LedControl library and max7219.

I've tried to write my own code, but it only shows 8888, and won't react to my setDigit command.
I do manage to turn on/off the power-saving mode.

I then tried to upload a few example codes, but the same thing happens.

I use pin 5 instead of pin 12, like used in the example codes.
LedControl lc=LedControl(5,11,10,1);

Is it somebody out there who can help me with this? :slight_smile:

You will need to post your cirtcuit and your code. If you don't have a circuit, pictures of your (breadboard?) setup would be ok.

Hard to help if we can't see what is made.

I will make a schematic of my setup when I get back from work!

I found an old forum thread saying something about arduino nano not being compatible with the SPI code in arduinos language. Is that so?

Here is one of the example codes I've been using:

//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 5 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(5,11,10,1);

/* we always wait a bit between updates of the display */
unsigned long delaytime=250;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}

/*
  This method will scroll all the hexa-decimal
 numbers and letters on the display. You will need at least
 four 7-Segment digits. otherwise it won't really look that good.
 */
void scrollDigits() {
  delay(delaytime);  
  
  lc.setDigit(0,0,1,false);

    delay(delaytime);
  
  lc.clearDisplay(0);
  delay(delaytime);
}

void loop() { 
  scrollDigits();
}

I tried one of my arduino unos instead of the nano, but there was no difference...

I've used both my breadboard and soldered it to a prototypeboard with wires running between the points. A friend told me he had problems using breadboards with data transmission because of capacitance in the board.

Here is the schematic:

What happens if you use the 7Segment demo included with the LedControl library?

//We always have to include the library
#include "LedControl.h"

/*
 Now we need a LedControl to work with.
 ***** These pin numbers will probably not work with your hardware *****
 pin 5 is connected to the DataIn 
 pin 11 is connected to the CLK 
 pin 10 is connected to LOAD 
 We have only a single MAX72XX.
 */
LedControl lc=LedControl(5,11,10,1);

/* we always wait a bit between updates of the display */
unsigned long delaytime=250;

void setup() {
  /*
   The MAX72XX is in power-saving mode on startup,
   we have to do a wakeup call
   */
  lc.shutdown(0,false);
  /* Set the brightness to a medium values */
  lc.setIntensity(0,8);
  /* and clear the display */
  lc.clearDisplay(0);
}


/*
 This method will display the characters for the
 word "Arduino" one after the other on digit 0. 
 */
void writeArduinoOn7Segment() {
  lc.setChar(0,0,'a',false);
  delay(delaytime);
  lc.setRow(0,0,0x05);
  delay(delaytime);
  lc.setChar(0,0,'d',false);
  delay(delaytime);
  lc.setRow(0,0,0x1c);
  delay(delaytime);
  lc.setRow(0,0,B00010000);
  delay(delaytime);
  lc.setRow(0,0,0x15);
  delay(delaytime);
  lc.setRow(0,0,0x1D);
  delay(delaytime);
  lc.clearDisplay(0);
  delay(delaytime);
} 

/*
  This method will scroll all the hexa-decimal
 numbers and letters on the display. You will need at least
 four 7-Segment digits. otherwise it won't really look that good.
 */
void scrollDigits() {
  for(int i=0;i<13;i++) {
    lc.setDigit(0,3,i,false);
    lc.setDigit(0,2,i+1,false);
    lc.setDigit(0,1,i+2,false);
    lc.setDigit(0,0,i+3,false);
    delay(delaytime);
  }
  lc.clearDisplay(0);
  delay(delaytime);
}

void loop() { 
  writeArduinoOn7Segment();
  scrollDigits();
}

The same thing happens with the demo included with the library...

Where did the schematic go? Was going to go over it in detail but it's missing now.

I still see it. Anyway, here is the link: http://oi38.tinypic.com/b8aghz.jpg
Thank you for taking the time!

JonKjos:
I still see it. Anyway, here is the link: http://oi38.tinypic.com/b8aghz.jpg
Thank you for taking the time!

Ah, I think I see why now, I'm at work and the company blocks that URL

Looking at the diagram and comparing to what you have for the 7-Segment display pinout and wiring all seems good.
You show no connection for the DP segment on the display, this could be connected to pin 22 on the MAX7219 (assuming there is a decimal point on the display)
I would also connect a 0.1uF capacitor between VCC & GND near the MAX7219.
Where are you getting the MAX7219 power from? Are you feeding it from the arduino or a separate supply feeding both the MAX and the arduino?

Aha! Do you have the time when you get off work? I really have no idea!

Thank you for taking the time trying to help me!

I got my hand on another MAX7219, and tried that one out. Turns out the first one was broken!
That's how simple it can be sometimes! All these hours with hair pulling are finally over! :slight_smile:

Glad you got it sorted out.