Pages: [1] 2   Go Down
Author Topic: Arduino connected to LED matrix (MAX 7219)  (Read 2949 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi!

I am having a little problem with the LED matrix (“Max 7219”) that I recently purchased. The component is connected with transistors according to this sketch I found (http://www.arduino.cc/playground/uploads/Main/MAX72XX_SPI.jpg) and I have tried the following codes:
http://www.wiring.org.co/reference/libraries/Matrix/Matrix_.html
and also
http://www.arduino.cc/playground/LEDMatrix/Max7219 (but with the small change of wiring datain, load and clock to 2, 3 and 4 instead of what the photo shows).

Still, when I say that all the LEDs should be turned off/low, all of them are shining as bright as ever. If I tell one of them to blink, all of them are blinking (also, they are only blinking when the GND is disconnected). I don't think the LED matrix is faulty, because I have just bought a new one and it is an identical problem. This is the picture of the wiring (sorry for the wire mess):


Other people seems to have gotten this matrix to work with Arduino, any idea what I am doing differently? Also, I might add that I have had all the cables connected when loading the program over to Arduino, might that be the reason?

All help appreciated!

//Jenny

Logged

malmö / berlin
Offline Offline
Jr. Member
**
Karma: 0
Posts: 58
fhp>--vs--<k3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset


hej,

i would just suggest to not use pin 0 and 1 ( because there are the serial communication Pin of the arduino), maybe they interfere with the FTDI chip (USB port), which is connectect at your picture.

maybe post your code (or just this lines you changed)

good luck
tomek

Logged

Denver
Offline Offline
God Member
*****
Karma: 20
Posts: 779
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Jenny,

From the top photo (at least) it looks like the clock is going to pin 14 rather than 13. I'd also avoid using using Arduino pins 0 & 1 as tomek suggested. Sometimes it's also best to restart the sketch before testing so the chip get initialized properly.

What kind of a matrix are you using?

John
Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for the quick reply!

First of all, you are right that it looks like the clock goes to 14 instead of 13 but this is just a bad photo. If you look at the bottom photo, it is clear that it goes to the bottom right pin (though I agree with you - the photo is not brilliant in this respect). We haven't connected an LED display, just a single LED so far. Though when we move the cable between the DIG-pins, it is the same answer on all of them - the LED lights.

Second, this is the code I tried today:
      
#include <Binary.h>
#include <Sprite.h>
#include <Matrix.h>
 
Matrix myMatrix = Matrix(2, 4, 3); //changed from 0,2,1 after your comments, also changed wiring to 2, 3 and 4
 
void setup()
{
}
 
void loop()
{
  myMatrix.clear(); // clear display
 
  delay(1000);
  
  myMatrix.write(1, 5, HIGH);
 
  delay(1000);
}


As you can see, only one light is supposed to be turned on. This is how it is behaving with the code above:

1) Have the GND and 5+ connected => The LED lights up, disregarding what pin it is connected to and not blinking
2) Have the GND and 5+ disconnected => The LED lights up, disregarding what pin it is connected to and blinking

I am starting to wonder if the LED matrix is in a constant "shutdown mode" (been reading a bit in the data sheet) - could this be the case and how do I make it start working?

Also, when you say "restart the sketch" - do you mean closing down the Arduino program and opening it again? (which I tried just to be sure, but it did not change anything unfortunately)
Logged

Denver
Offline Offline
God Member
*****
Karma: 20
Posts: 779
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm actually more familiar with the LedControl library (http://www.arduino.cc/playground/Main/LedControl) where you must explicitly set up the chip and take it out of shutdown, etc. in the Setup function.

However, I looked at the source to the Matrix library and it looks like all that stuff is done for you. So the chip should be running without anything in Setup().

(Although you might try the LedControl library to see if there is a difference)

In trying to interpret that tricky picture again  smiley, it looks like you have the led connected to digit 2, segment c. Your code sample is not trying to light that. Although I know you said you tried different pins, connecting to them while the MAX7219 is running may not be the best for troubleshooting. (Note that the decimal point "DP" is the first column.)

I know this doesn't answer all your observations but it may spark an idea (so to speak).

John

PS By "restart the sketch" I meant pressing the reset button. For example, if you power up the chip after the program started, weird things will happen.
« Last Edit: February 06, 2008, 06:59:38 pm by BroHogan » Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hey,

I did try the LEDControl library but there was no difference, so I changed back to the wiring library. Also, I tried making an 7x6 matrix and ran it with this code:

/*
 pin 2: data  (din)
 pin 3: load  (load)
 pin 4: clock (clk)
 */

#include <Binary.h>
#include <Sprite.h>
#include <Matrix.h>

Matrix myMatrix = Matrix(2, 4, 3);

void setup()
{
}

void loop()
{
  myMatrix.clear(); // clear display
}

All the lights were turned on. But when I changed to an "all lights on, all lights off, delay 1 sek loop", they actually blinked (even with the GND and 5V in), which explains the problem I had before (too few LEDs -> too much power through the component will make the OFF close to as light as the ON state and therefore no visible blinking).

If anyone here of anyone having a similar problem/solution, please do tell me. I'll post here if it ever gets solved.

Thanks all!

//Jenny
Logged

Denver
Offline Offline
God Member
*****
Karma: 20
Posts: 779
Inactive - PM
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

//Jenny

Still trying to figure out your problem. My setup is a little different (2 x 7219 hard wired for 16 segments on 8 digits) so I have to pull a chip to get it similar to yours.

Using the LedControl, it works with your pinouts. i.e. . . .
Code:
/*  
 pin 2: data  (din)
 pin 3: load  (load)
 pin 4: clock (clk)
 */

#include "LedControl.h"
LedControl lc=LedControl(2,4,3,1); // forum pin outs

void setup()  
{  
  lc.setIntensity(0,8);
  lc.shutdown(0,false); // need to take MAX out of shutdown
  lc.clearDisplay(0);  
  delay(10);
}  

void loop()  
{  
  lc.clearDisplay(0);  
  delay(1000);
  lc.setLed(0,1,5,true);
  lc.setLed(0,2,2,true);
  lc.setLed(0,2,6,true);
  lc.setLed(0,3,6,true);
  lc.setLed(0,4,6,true);
  lc.setLed(0,5,2,true);
  lc.setLed(0,5,6,true);
  lc.setLed(0,6,5,true);
  delay(1000);
}

(But even with this lib, it won't work if I set it to use pin 0,1,&2 - all leds light)

But using the same setup with the Matrix lib (and pins 2,3,&4) mine doesn't work either. (As I said, it may be due to the board I have wired for the 2 MAX chips, but the LedControl did work.)

So I don't know what to tell you about that lib, since I can't get a known good configuration working with it either. It's a bone head mistake I'm sure, so I'll post the non-working code below . . .

Code:
#include <Binary.h>  
#include <Sprite.h>  
#include <Matrix.h>  
 
Matrix myMatrix = Matrix(0, 2, 1);  // orig example - no joy
//Matrix myMatrix = Matrix(2, 4, 3);  // forum example - no joy
 
void setup()  
{  
myMatrix.setBrightness(7);
}  
 
void loop()  
{  
myMatrix.clear(); // clear display
   delay(1000);
 
  // turn some pixels on
  myMatrix.write(1, 5, HIGH);
  myMatrix.write(2, 2, HIGH);
  myMatrix.write(2, 6, HIGH);
  myMatrix.write(3, 6, HIGH);
  myMatrix.write(4, 6, HIGH);
  myMatrix.write(5, 2, HIGH);
  myMatrix.write(5, 6, HIGH);
  myMatrix.write(6, 5, HIGH);
   delay(1000);
}

Sorry, I couldn't be of more help. At least you can try the LedControl lib again to see if my example works.

John
Logged

"Data is not information, information is not knowledge, knowledge is not understanding, understanding is not wisdom."
~ Clifford Stoll

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks so much for the LEDControl code!

I tried it but everything still lights up (though it is a true comfort that the other pieces of code did not work for you either). This is really getting bizarre, I am going to try all this from a windows computer (instead of my macbook), because I want to eliminate all other reasons than the pure software related ones smiley

//Jenny
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Jenny,

Just curious, did you get this working? I'm trying the same now, using only 1 row of dig0 to all LED cathodes and then anodes to their respective SEG pins. I have 8 in the row but yea again either all are lit or none.
Does the entire matrix have to be set up first before this can work? It seems like it should be able to work with just 1 row with all 8 LED's connected...
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 12
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi Nemik,

Funny that you should mention it because I actually got it to work today. The only way my LedControl code differs from BroHogan is that I, instead of using clearDisplay(0), set all the LEDs to false (by using lc.setLed(0,i,j,false) in a double for loop). Hopefully, it works for you as well!

//Jenny
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

So was that what was needed to get it working? Or some circuit changes as well?

I haven't yet tried the LedControl library. Still holding my breath and hoping I can get it with Matrix.h!

Glad you got it working though and thanks for the update.
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,
my name is Eberhard and I wrote the LedControl-library. Your solution :
Quote
Hi Nemik,

Funny that you should mention it because I actually got it to work today. The only way my LedControl code differs from BroHogan is that I, instead of using clearDisplay(0), set all the LEDs to false (by using lc.setLed(0,i,j,false) in a double for loop).
.. is quite surprising to me, so I went through my library-code again without coming to an idea why LedConrol.clearDisplay() should not work ????

Anyway, you found a solution,thats fine! But as a suggestion : you can also call LedControl.setRow() to clear the display. It will actually be much faster since it needs only 8  write-commands to the MAX7221 instead of 64 with the setLed solution. Code should be something like
Code:
void clearByRows(int address) {
    for(int i=0;i<8;i++) {
        lc.setRow(address,i,0);
    }
}

BTW. Don't try setColumn() for this since this function uses setLed() internally so nothing would be gained.

Do you mind sending me your code, so I could try it with my hardware?

Eberhard Fahle
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 40
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry if this is a stupid question, but I'm having similar problems to what Jenny had before. When GRD is connected, all LED's are very bright and do not blink, they all blink though if GND disconnected. I'm using the +5V and GND from the arduino over a laptop USB which allows 500mA and should be enough.

Also, I don't have a pre-built matrix and I'm making my own 2x2 or 3x3 one on the breadboard. However for one smaller than 8x8, do I need to adjust anything in the code? Do the LedControl or Matrix libraries always assume 8x8 and therefore require all 64 LEDs to be connected? Do I need to change the scanLimit or something like that to properly work a 2x2 or 3x3?

thanks!
Logged

Wuppertal/Germany
Offline Offline
God Member
*****
Karma: 1
Posts: 895
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi nemik,
Quote
Sorry if this is a stupid question, but I'm having similar problems to what Jenny had before. When GRD is connected, all LED's are very bright and do not blink, they all blink though if GND disconnected. I'm using the +5V and GND from the arduino over a laptop USB which allows 500mA and should be enough.
Someone else reported strange effects because he wired the LEDs on on a matrix the wrong way round. They were all inverted and the effects are similar to the ones reported in this topic here. Could you check that for your matrix?

Quote
Also, I don't have a pre-built matrix and I'm making my own 2x2 or 3x3 one on the breadboard. However for one smaller than 8x8, do I need to adjust anything in the code? Do the LedControl or Matrix libraries always assume 8x8 and therefore require all 64 LEDs to be connected? Do I need to change the scanLimit or something like that to properly work a 2x2 or 3x3?
No to all these questions. The LedControl-lib doesn't care if you attach only small matrix, you can connect  a single Led and it should work properly.

Eberhard


Logged

Brisbane, Australia
Offline Offline
God Member
*****
Karma: 1
Posts: 593
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Someone else reported strange effects because he wired the LEDs on on a matrix the wrong way round. They were all inverted and the effects are similar to the ones reported in this topic here. Could you check that for your matrix?
Not exactly the same but it was acting extremely weird and nothing like the program was telling it to do.
Logged

Pages: [1] 2   Go Up
Jump to: