Newbie: MAX7219 Problem LED's all are lit however NO TEXT

Hi,
I’m a Senior Citizen (late 70’s) and an Arduino Newbie, totally. I thought a nice thing for Grandkids is to make a scrolling text sign. I bought a Mega 2560 Rev 3 and a MAX7219.

Not wanting to jump right into scrolling (and before plugging in the LED matrix) I did a very basic Sketch (I saw on YouTube) to turn on/off the LED on the Arduino board. I even added a delay after ON and after OFF and was excited to see it worked perfect.

Next, I found the MD_MAX72XX Print Text example in the Library and Installed it (figuring this was the next step before I try scrolling).

I read as much as possible before wiring/using the MAX7219. People said when using a MAX7219 to replace “PAROLA_HW” with “FC16_HW” so I did that and changed the number of devices from 11 to 4 (I assumed a bank of 64 LEDs is 1 device)

.......
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
.......
It then Compiled and Uploaded perfectly (I was very happy it uploaded with No Errors)

My PROBLEM is that, when it completed uploading, all 4 banks of 64 Green LED’s lit up and stayed lit. And NO "Hello" Text was showing.

I rechecked my wiring….and for the heck of it, I uploaded the Example Sketch WITHOUT making the change to “FC16_HW” and without changing the number of devices…..same result; no errors, however leds all lit and stayed lit and no text.

Being new to Arduino and new to this forum….I hope I picked the right Category to post my comment.

I would really appreciate if someone could tell me what I might be doing wrong.

(I Googled and YouTubed for a day trying to see if I could find a solution. No help there.)

Thank You, Richard

Good thinking.

Again, good thinking.

You have omitted some details.

  1. The MAX7219 is a chip, not a display. Can you please post a URL (link) of what you bought?
  2. Your code; the easiest way is to use tools -> autoformat in the IDE followed by edit -> copy for forum; next paste it in a reply.

You did not post in the correct category as you can upload :wink: It has been moved to a more suitable location on the forum.

OK, sounds good so far.

I gather you have this four matrix FC-16 strip:

So what is the problem? You have not got the correct connections. Please show your connections as a diagram and as a photo. It is unfortunate you have a Mega 2560 as the connections are different.

Please also read the instructions and post your code. The "FC-16" version if as I presume, that is the version you have. (it may be written on the PCB.)

There is auto test if I remember correctly that lights up all the LEDs, part of hardware functionality that can be disabled. Maybe the command that is switching it off is missing from the code

Is it possible the displays have been incorrectly rotated 180 degrees before they were inserted in their sockets?

Thank you all for your reply. Hopefully I can answer all your questions. In doing so, did not reply to each person, figuring it's best to reply in the post.....is that correct?

Here are my responses:

(1) The weblink for the specific MAX7219 item I have is:

(2) I'm assuming (?) the displays are not incorrectly rotated 180 degree since I tried both units as purchased right out of the package.

(3) I was asked for my wiring schematic, photo of hardware and full sketch code.
I tried to attach 1 schematic and 4 photos, but when trying to post it said as a new user I am only allowed One upload attachment, so I chose the Schematic. Didn't know what esle to do.

I saved the code using "copy for forum" and will paste it here:

// Use the MD_MAX72XX library to Print some text on the display
//
// Demonstrates the use of the library to print text.
//
// User can enter text on the serial monitor and this will display as a
// message on the display.

#include <MD_MAX72xx.h>
#include <SPI.h>

#define PRINT(s, v) { Serial.print(F(s)); Serial.print(v); }

// Define the number of devices we have in the chain and the hardware interface
// NOTE: These pin numbers will probably not work with your hardware and may
// need to be adapted
#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4

#define CLK_PIN   13  // or SCK
#define DATA_PIN  11  // or MOSI
#define CS_PIN    10  // or SS

// SPI hardware interface
MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);
// Arbitrary pins
//MD_MAX72XX mx = MD_MAX72XX(HARDWARE_TYPE, DATA_PIN, CLK_PIN, CS_PIN, MAX_DEVICES);

// Text parameters
#define CHAR_SPACING  1 // pixels between characters

// Global message buffers shared by Serial and Scrolling functions
#define BUF_SIZE  75
char message[BUF_SIZE] = "Hello";
bool newMessageAvailable = true;

void readSerial(void)
{
  static uint8_t	putIndex = 0;

  while (Serial.available())
  {
    message[putIndex] = (char)Serial.read();
    if ((message[putIndex] == '\n') || (putIndex >= BUF_SIZE-3))  // end of message character or full buffer
    {
      // put in a message separator and end the string
      message[putIndex] = '\0';
      // restart the index for next filling spree and flag we have a message waiting
      putIndex = 0;
      newMessageAvailable = true;
    }
    else
      // Just save the next char in next location
      message[putIndex++];
  }
}

void printText(uint8_t modStart, uint8_t modEnd, char *pMsg)
// Print the text string to the LED matrix modules specified.
// Message area is padded with blank columns after printing.
{
  uint8_t   state = 0;
  uint8_t   curLen;
  uint16_t  showLen;
  uint8_t   cBuf[8];
  int16_t   col = ((modEnd + 1) * COL_SIZE) - 1;

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::OFF);

  do     // finite state machine to print the characters in the space available
  {
    switch(state)
    {
      case 0: // Load the next character from the font table
        // if we reached end of message, reset the message pointer
        if (*pMsg == '\0')
        {
          showLen = col - (modEnd * COL_SIZE);  // padding characters
          state = 2;
          break;
        }

        // retrieve the next character form the font file
        showLen = mx.getChar(*pMsg++, sizeof(cBuf)/sizeof(cBuf[0]), cBuf);
        curLen = 0;
        state++;
        // !! deliberately fall through to next state to start displaying

      case 1: // display the next part of the character
        mx.setColumn(col--, cBuf[curLen++]);

        // done with font character, now display the space between chars
        if (curLen == showLen)
        {
          showLen = CHAR_SPACING;
          state = 2;
        }
        break;

      case 2: // initialize state for displaying empty columns
        curLen = 0;
        state++;
        // fall through

      case 3:	// display inter-character spacing or end of message padding (blank columns)
        mx.setColumn(col--, 0);
        curLen++;
        if (curLen == showLen)
          state = 0;
        break;

      default:
        col = -1;   // this definitely ends the do loop
    }
  } while (col >= (modStart * COL_SIZE));

  mx.control(modStart, modEnd, MD_MAX72XX::UPDATE, MD_MAX72XX::ON);
}

void setup()
{
  mx.begin();

  Serial.begin(57600);
  Serial.print("\n[MD_MAX72XX Message Display]\nType a message for the display\nEnd message line with a newline");
}

void loop()
{
  readSerial();
  if (newMessageAvailable)
  {
    PRINT("\nProcessing new message: ", message);
    printText(0, MAX_DEVICES-1, message);
    newMessageAvailable = false;
  }
}

Zf.jpeg)51

I am somewhat perplexed by the code you are using, but it appears it uses the hardware SPI.

As I pointed out, you are (unfortunately :grin:) using a Mega 2560 whose hardware is different.

Apparently the code for the Mega is

#define CLK_PIN   52  // or SCK
#define DATA_PIN  51  // or MOSI
#define CS_PIN    53  // or SS

And you need to wire it accordingly.


Just noticed:

I suggest you do not connect anything to "Vin" or the "barrel jack". Ever! :cold_sweat:

And finally, if you put a 10 or 47k pull-down on the CS_PIN, it should not all light up on startup.

The code is a straight example from the library and as shown will use the hardware SPI. The #defines don't do anything in this mode except remind novices (who by and large will use an Uno) which pins need connecting, So if you are using a MEGA the pins will be different, as pointed out by Paul.

1. Connection diagram (Fig-1) between MEGA and MAX7219 based Led Matrix Display Unit.


Figure-1:

2. You may follow this tutorial:
MAX7219 Based Led Matrix Display

Thank you so much for all your replies and great information.

Can you show me how to "put a 10 or 47k pull-down on the CS_PIN" via words or schematic
(I do have a 10K and a 47K resistor)
Anxious to try this once I install (if that's the right word) the pull-down resitor.

Just wire it from that pin to ground. As well as the other connection.

Go on. Why would you have a pulldown resistor on an active-low /CS pin ?

From the MAX7219 datasheet it is a regular SPI mode#0 device with active-low /CS. (unless I have missed the plot somewhere)

David.

Paul thank you.......it worked perfectly. I then did a Parola Sketch (changing the parameters you mentioned).....and it worked perfectly. Thank you so very much (and the others for sure) for solving my Newbie Problem. My Grandkids will love "Poppie's new invention"......ha.
How do I properly note in this Post that this problem is solved?
As an aside, am I able to upload a video clip to the forum??

As the originator of the thread, I think you should see a checkbox at the bottom of each post ("Solution") and you just check the one that you think solved the problem.

This is not an active low pin. This is, in fact, the LOAD pin of MAX7219. To latch data into the register of MAX7219, a LOW-HIGH-LOW pulse is to be applied to this CS-pin after SPI.transfer() instruction. To stop the initial turning on of the LEDs (due to random interference at start up), it is recommended to assert LOW at CS-pin by a pull-down resistor.

To prevent random interference clocking rubbish into the MAX7219 as the microcontroller boots and its pins are open circuit.

Looking at Figure 1. Timing Diagram in the MAX219 datasheet
image

it seems pretty much like SPI #0.

David.

Look at Fig-1 (below), LOAD (rising edge) is for MAX7219 and CS/ (active Low) is for MAX7221.
max7219Pin


Figure-1:

Whether you call it LOAD or /CS nothing gets latched into the MAX72xx chip until you have a rising edge.

image

General rule with SPI devices. Use external pullup on /CS pin so that the device is inactive until the microcontroller asserts control. (at reset the AVR pins are all input and wobbly)

I will dig out a MAX7219 later and see how it behaves.

David.

Codes from an application program of a MAX7219 based product (Digital Weighing Scale). Here, the LOAD-pin of MAX7219 is pulsed L-H-L to latch data.

void dataLoad()
{
  digitalWrite(LOAD, HIGH);
  delayMicroseconds(1);
  digitalWrite(LOAD, LOW);
}