[SOLVED] Interfacing 7 segment display with MAX7219

I bought MAX7219EWG chips and I already have a lot of common-cathode 7 segment displays. I used the LedControl library for the Arduino for testing purposes.

Firstly I just wanted to see if only one single 7 segment display will work.

I hooked up all the segments to the chip, I connected DIG0 to the common cathode of the display, DataIn to pin 12 of the arduino, CLK to pin 11, and finally LOAD to pin 10. I hooked up the ground and +5V, uploaded the program and I saw nothing.

I checked all the wiring and I don't think that's the problem. Then I thought maybe the display itself is not working and I got a common-anode display just so I can test it with that. I hooked it up and it lit up, constantly showing the number 8, basically all the leds are on. It's kinda weird. I looked at the datasheet of the MAX7219 and it says it's for driving common-cathode displays, but in my case it doesn't work.

I am sure that the displays I have work since I have used them in other projects and also I am sure that they are common-cathode because I tested them with a multimeter.

Can someone please suggest a solution to this.

Any help will be appreciated.

Thanks in advance.

I got the common-cathode to light up, apparently I forgot to add the resistor between +5v and ISET pin. But still, all the leds are on the display. I can't get it to show numbers

You need code to produce a display. :astonished:

By the way, read the instructions for posting code! (Item 7)

#include "LedControl.h"

LedControl lc=LedControl(12,11,10,1);

void setup() {
  lc.shutdown(0,false);
  lc.setIntensity(0,8);
  lc.clearDisplay(0);
}

void loop() { 
  lc.setDigit(0,0,'3',false); 
}

Here is the code I used. I modified this sketch:

I tried lc.setDigit(0, 0, 3, false), without the apostrophe or however you call this symbol ', but with no luck.

Hmmm. Using the "LedControl" library. I am afraid I am not at all familiar with that and the documentation on the Arduino site is truly terrible (fails to give a concise listing of the functions - or did I just not find it?)!

As far as I can see, you appear to be using correct codes. Later I will find some software SPI code for you to try but for the moment, please give us some adequately lit photos of your arrangement to see if anything stands out. :grinning:

The “LedControl” library has a good documentation inside the header file. That’s where I looked up all the functions and what they do. I think I did everything correctly.

As for the pictures… It’s a mess, since the MAX7219 I ordered are SMD and I just soldered longer pins to it so I can put it on a breadboard for testing.

I just wanted to see the results before I start making a proper PCB. I will try my best to take pictures, or better yet, I can just make the circuit in Fritzing or some other software like that and post a picture of that.

LanternMG:
or better yet, I can just make the circuit in Fritzing or some other software like that and post a picture of that.

That would not tell us what mistake you made, would it?

I advise the use of these for prototyping - or indeed end use with custom displays.

They are useful for any application except moving message displays (in which case you need the FC-16s instead).

Those are not that useful for me. I already have 7 segment displays that I need to use in a project and I already received the MAX7219 chips (20 of them), so I strictly need 7 segment displays (20 in a row for now) for my application. I planned on ordering those 4 digits 7 segment displays with the max chip in there so i can just plug it in the arduino and be done with it, but I didn't since I already have the displays and I like the challenge to make this work now.

Today I got the chance to find a SPI example for the chip and tried it, but I got the same result. All the LEDs are on.

I really have no idea what I'm doing wrong. I will take pictures later and post them here.

I took some pictures, I don't know how much of it you can see, as I said... It's a mess. And yes I know that the Segment E is not connected (Pin 21 on the MAX7219), the pin I soldered fell off, but I just want to see numbers changing on the display, then I will make a proper PCB.

Also I know I don't need the resistor connected to the common-cathode, but I just put it there to make the display dimmer.

Here are the pictures:

Hi,

Please read the first post in any forum entitled how to use this forum.
http://forum.arduino.cc/index.php/topic,148850.0.html .
It will show you how to integrate you images and links into your posts.

Can you please post a copy of your circuit, in CAD or a picture of a hand drawn circuit in jpg, png?

Thanks.. Tom.. :slight_smile:
PS one of OPs images;

Yeah, sorry about that, I thought that you can only add attachments and the pictures I have are well over 2 MB, so I posted the links. I didn't know you can add image directly from a link. Thanks for that.

Here is just one link of all the images, I thought it might be faster this way.

There is a image of the circuit as well.

Hi,
I don't think you need the resistor from pin2 to the common cathode of the display, just connect them directly.
The current is controlled by the chip and the ISet resistor.

Tom... :slight_smile:

Hi,
Your circuit should be something like this.

But you need to draw your own from your project to check for any wiring discrepancies.

Tom.. :slight_smile:
PS you can reduce the size of your image files and still have good resolution.

Hi,
Check your code and wiring.

 pin 12 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(12,11,10,1);

You need to connect your max chip to 12,11,10, not 5,6,7 you have in your project.

Tom.... :slight_smile:

Hi Tom,

I wrote in one my previous replies that I put that resistor to pin 2 just so I can dim the display a little bit. I have tried removing it but I still have the same problem.

And about the 12, 11, 10 pins, sorry once again. I was testing a different sketch with pins 7, 6, 5 and I forgot to put the wires back to their original place on the pictures.

After much playing around, I found out that the MAX7219 chip that I ordered doesn't work well with only one digit. I hooked up 2 more (3 in total) and the "LedControl" library finally works.

Thanks for anyone who tried to help in any way.

I hope someone finds this useful sometime in the future.

LanternMG:
I wrote in one my previous replies that I put that resistor to pin 2 just so I can dim the display a little bit. I have tried removing it but I still have the same problem.

Since the MAX7219 is attempting to correct your mistake.

You dim the display by using an appropriate value of the Iset resistor (as well as the intensity register).

LanternMG:
After much playing around, I found out that the MAX7219 chip that I ordered doesn't work well with only one digit.

It works just fine with only one digit. What did you do wrong (code) to make it misbehave?

I took the resistor out once I got everything working and it doesn't make a difference (except the brightness a little bit).

And I didn't do anything wrong in the code. I just loaded the example from the LedControl library, changed the pin numbers and that's it. Just like I did before hooking up the remaining 2 displays.

I didn't change anything else to the hardware beside the additional 7 segment displays.

This is my first time using the MAX7219 and I don't exactly know how it works. If you say it works with only one display, then it must work...but not in my case and i have no idea why. I still have 2 capacitors between +5V and GND, I didn't touch those. And I even tried putting 220 Ohm resistors on each of the common-cathode of the 3 displays and it works, so i know they are not the problem.

The only thing I changed was adding more displays, so that is the only thing I suspect. I can't speak for others, it might work with one display. But for me, it didn't. That's why I asked the question on the forum.

I always do some research before posting on forums. Forums were my last resort.

The point is - did you change the code when you used one display or more, and in what way did it not work?

LanternMG:
changed the pin numbers and that's it.

So what does that mean? What did you actually change?

LanternMG:
I didn't change anything else to the hardware beside the additional 7 segment displays.

I take that to imply that you did change the code in some way.

Putting resistors in the common cathode lines makes no sense at all; the only possible effect will be to make the brightness vary with different numbers of segments lit, which is just one of the reasons you want to use a MAX7219 in the first place since it is designed specifically to prevent that.

I used the same exact code (the LedControl library LCDemo7Segment example code) for one digit and for three digits. I didn't change anything there.

The only thing I changed in the code was this:

LedControl lc=LedControl(12,11,10,1);//This is the original line from the example code

LedControl lc=LedControl(2,3,4,1); //This is what's in my code

And instead of plugging the MAX7219 into pins 12, 11, 10...I plugged the DIN to pin 2, CLK to pin 3 and LOAD(CS) to pin 4.

Everything else remained the same.

The example code firstly prints "Arduino" letter by letter on the first digit. That's why this code should work with one and three digits. I should've at least seen the "Arduino" being printed on the first digit, but I didn't, not until I added the remaining two displays.

Putting resistors in the common cathode lines makes no sense at all; the only possible effect will be to make the brightness vary with different numbers of segments lit, which is just one of the reasons you want to use a MAX7219 in the first place since it is designed specifically to prevent that.

I had no idea about that. Thank you for enlightening me sir.

Unfortunately, a new problem arose. I use serial to send data from my pc to the arduino and then show the value sent to the 3 digit 7 segment display. If the numbers I send have more then 2 eigths in them (when all the leds are activated), the MAX7219 freezes up and I have to reset the arduino.

I tried lowering the brightness to the lowest it goes but that didn't do anything beside dimming the screen (I thought it would pull less amps from the arduino). So my guess is that the chip is damaged or something like that.