Go Down

Topic: 4 column, 5 row LED MATRIX with MAX7219 (Read 4184 times) previous topic - next topic

patplanet

Hello,
I am new to this forum and programming with the arduino, so forgive me. I am eventually going to make an 8x8 led matrix, but I am currently prototyping on a breadboard with a 4x5 matrix. I am using the MAX7219 chip and the LEDCONTROL library. So, I have constructed the circuit below, and the code as follows, but the led's won't even light up at all when running the code. I'm not sure if I fried the chip or have an error in the circuit and/or code. Does anyone have any ideas?



Code: [Select]

//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 3 is connected to the DataIn
pin 2 is connected to the CLK
pin 4 is connected to LOAD
We have only a single MAX72XX.
*/
LedControl lc=LedControl(3,2,4,1);

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

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 function will light up every Led on the matrix.
The led will blink along with the row-number.
row number 4 (index==3) will blink 4 times etc.
*/
void single() {
  for(int row=0;row<5;row++) {
    for(int col=0;col<4;col++) {
      delay(delaytime);
      lc.setLed(0,row,col,true);
      delay(delaytime);
      for(int i=0;i<col;i++) {
        lc.setLed(0,row,col,false);
        delay(delaytime);
        lc.setLed(0,row,col,true);
        delay(delaytime);
      }
    }
  }
}

void loop() {
  single();
}

johnwasser

I can't see how you have the 5 anode and 4 cathode (or 4 anode and 5 cathode) wires connected from the driver chip to your matrix.  It looks like you have Digit drivers 0,1,2,,4,and 6 all shorted together. Similarly Segments drivers A, B, C, and DecimalPoint appear to be shorted together.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

patplanet

Wow, that was a big mistake. I misinterpreted the schematic and didn't realize that I was shorting out all of those pins. I tried to correct that mistake, but the led's still don't light up. I guess those shorted wires fried the chip, but I'm not sure.

johnwasser

It is possible you have the LEDs backwards?  Try swapping the Digit and Segment drivers to drive the LEDs the other way.
Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

patplanet

It looks like that worked :) , but the only thing is that when I run the program, the example program doesn't seem to be working properly. When I run the program, the LED's complete the start-up procedure (getting out of power-saving mode), but then all of them light up instead of performing what it is supposed to do. Here is the code I tried (different from above):

Code: [Select]

//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 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(3,2,4,1);

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

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 the matrix.
(you need at least 5x7 leds to see the whole chars)
*/
void writeArduinoOnMatrix() {
 /* here is the data for the characters */
 byte a[5]={B01111110,B10001000,B10001000,B10001000,B01111110};
 byte r[5]={B00111110,B00010000,B00100000,B00100000,B00010000};
 byte d[5]={B00011100,B00100010,B00100010,B00010010,B11111110};
 byte u[5]={B00111100,B00000010,B00000010,B00000100,B00111110};
 byte i[5]={B00000000,B00100010,B10111110,B00000010,B00000000};
 byte n[5]={B00111110,B00010000,B00100000,B00100000,B00011110};
 byte o[5]={B00011100,B00100010,B00100010,B00100010,B00011100};

 /* now display them one by one with a small delay */
 lc.setRow(0,0,a[0]);
 lc.setRow(0,1,a[1]);
 lc.setRow(0,2,a[2]);
 lc.setRow(0,3,a[3]);
 lc.setRow(0,4,a[4]);
 delay(delaytime);
 lc.setRow(0,0,r[0]);
 lc.setRow(0,1,r[1]);
 lc.setRow(0,2,r[2]);
 lc.setRow(0,3,r[3]);
 lc.setRow(0,4,r[4]);
 delay(delaytime);
 lc.setRow(0,0,d[0]);
 lc.setRow(0,1,d[1]);
 lc.setRow(0,2,d[2]);
 lc.setRow(0,3,d[3]);
 lc.setRow(0,4,d[4]);
 delay(delaytime);
 lc.setRow(0,0,u[0]);
 lc.setRow(0,1,u[1]);
 lc.setRow(0,2,u[2]);
 lc.setRow(0,3,u[3]);
 lc.setRow(0,4,u[4]);
 delay(delaytime);
 lc.setRow(0,0,i[0]);
 lc.setRow(0,1,i[1]);
 lc.setRow(0,2,i[2]);
 lc.setRow(0,3,i[3]);
 lc.setRow(0,4,i[4]);
 delay(delaytime);
 lc.setRow(0,0,n[0]);
 lc.setRow(0,1,n[1]);
 lc.setRow(0,2,n[2]);
 lc.setRow(0,3,n[3]);
 lc.setRow(0,4,n[4]);
 delay(delaytime);
 lc.setRow(0,0,o[0]);
 lc.setRow(0,1,o[1]);
 lc.setRow(0,2,o[2]);
 lc.setRow(0,3,o[3]);
 lc.setRow(0,4,o[4]);
 delay(delaytime);
 lc.setRow(0,0,0);
 lc.setRow(0,1,0);
 lc.setRow(0,2,0);
 lc.setRow(0,3,0);
 lc.setRow(0,4,0);
 delay(delaytime);
}

/*
 This function lights up a some Leds in a row.
The pattern will be repeated on every row.
The pattern will blink along with the row-number.
row number 4 (index==3) will blink 4 times etc.
*/
void rows() {
 for(int row=0;row<5;row++) {
   delay(delaytime);
   lc.setRow(0,row,B10100000);
   delay(delaytime);
   lc.setRow(0,row,(byte)0);
   for(int i=0;i<row;i++) {
     delay(delaytime);
     lc.setRow(0,row,B10100000);
     delay(delaytime);
     lc.setRow(0,row,(byte)0);
   }
 }
}

/*
 This function lights up a some Leds in a column.
The pattern will be repeated on every column.
The pattern will blink along with the column-number.
column number 4 (index==3) will blink 4 times etc.
*/
void columns() {
 for(int col=0;col<4;col++) {
   delay(delaytime);
   lc.setColumn(0,col,B10100000);
   delay(delaytime);
   lc.setColumn(0,col,(byte)0);
   for(int i=0;i<col;i++) {
     delay(delaytime);
     lc.setColumn(0,col,B10100000);
     delay(delaytime);
     lc.setColumn(0,col,(byte)0);
   }
 }
}

/*
This function will light up every Led on the matrix.
The led will blink along with the row-number.
row number 4 (index==3) will blink 4 times etc.
*/
void single() {
 for(int row=0;row<5;row++) {
   for(int col=0;col<4;col++) {
     delay(delaytime);
     lc.setLed(0,row,col,true);
     delay(delaytime);
     for(int i=0;i<col;i++) {
       lc.setLed(0,row,col,false);
       delay(delaytime);
       lc.setLed(0,row,col,true);
       delay(delaytime);
     }
   }
 }
}

void loop() {
 writeArduinoOnMatrix();
 rows();
 columns();
 single();
}

patplanet

I think I have the polarity correct on the led's with the anodes connected to DIG pins and cathodes connected to SEG pins, but ALL of the led's light up. If I switch the anodes to SEG pins and cathodes to DIG pins, NO led's light up. I seem to have a similar problem to this thread: <http://arduino.cc/forum/index.php/topic,11453.0.html>. Can someone help?

johnwasser

It's impossible to tell from your picture exactly how the LEDs are wired.

Start with just one LED connected between one Digit pin and one Segment pin.  See if you can get that one LED to turn on and off.  Once you do that, try one digit and two segments.  See if you can control the two segments separately.  Then go to two Digits with two segments each.  If you can control all four LEDs separately you should be able to expand up to 8 digits and 8 segments.

Send Bitcoin tips to: 1G2qoGwMRXx8az71DVP1E81jShxtbSh5Hp
See who has no social life: https://forum.arduino.cc/index.php?action=stats :)

patplanet

I have tried all of your suggestions, and it still won't work. I even created a new led matrix on perfboard and bought a new chip, but I still have the same problem. I don't know what to do. Could my problem have something to do with the address of the matrix in the code (e.g. since I only have 1 max7219 chip, would the lc.setLed address parameter be "0")?

patplanet

Nevermind -  after all of that, it turns out that my problem was I didn't connect the SEG pin to +5V. IT IS FINALLY WORKING!  :D Thank you so much for your help though, it is much appreciated.

Go Up