9
\$\begingroup\$

I have:

Q: I just wonder how can I connect that to the Arduino Duemilanove?

I have been googling but I couldn't find out how.

\$\endgroup\$
2
  • \$\begingroup\$ @Bruno - You removed the link, so I thought it was dead. But it's OK, and you didn't explain why you deleted, so I rolled back. If you have a good reason to delete the link, please leave it in the comment field. \$\endgroup\$
    – stevenvh
    Commented Sep 10, 2012 at 12:59
  • \$\begingroup\$ @stevenvh Sorry, I tested it before and it was not working. Maybe I was having some Internet connectivity problems but it's working now. You did well rolling back my edit. \$\endgroup\$ Commented Sep 10, 2012 at 13:08

2 Answers 2

11
\$\begingroup\$

Bryan Chung had a tutorial still available on the Internet Archive on how to connect a LED Matrix to an Arduino using a MAX7219:

Here is an experiment with an 8×8 LED matrix, driven by a MAX7219 IC, controlled through an Arduino micro-controller board. A custom PCB has been made by Tan from DinoTech to tidy up all the wires connecting the LED matrix and the IC. It comes with a separate 12V power supply, in order not to drain everything from the Arduino board.

Only 4 wires are necessary to control the MAX7219 driver IC. They are the

Data Clock Latch/load Ground

The data and clock pins should match those for the shiftOut() command in Arduino. The latch pin will give a LOW to HIGH pulse after the shiftOut command. I have written the original program for Javelin Stamp. Since Arduino can only shift 8 bits of data, I have to use 2 separate commands to shift both the upper and lower bytes to the MAX7219, which needs a 2 bytes control for each command.

For the data structure of the 8×8 LED matrix, I use a byte array – matrix of length 8. Each row in the matrix corresponds to the Y dimension. Each bit in a row corresponds to the X dimension. Digit 1 is on; 0 is off. The X direction is reversed and there is also an 1 bit shift. The updateLED() function caters for this.

The first program is an animation of a single line motion.

int CLOCK = 12;
int LATCH = 13;
int DATA  = 11;
byte matrix[8];
int idx = 0;

void setup() {
  pinMode(CLOCK, OUTPUT);
  pinMode(LATCH, OUTPUT);
  pinMode(DATA,  OUTPUT);
  digitalWrite(CLOCK, LOW);
  digitalWrite(LATCH, LOW);
  digitalWrite(DATA,  LOW);
  initLED();
  clearLED();
}

void loop() {
  for (int j=0;j<8;j++) {
    updateLED(idx, j, true);
  }
  refreshLED();
  delay(200);
  for (int j=0;j<8;j++) {
    updateLED(idx, j, false);
  }
  refreshLED();
  delay(100);
  idx++;
  idx %= 8;
}

void ledOut(int n) {
  digitalWrite(LATCH, LOW);
  shiftOut(DATA, CLOCK, MSBFIRST, (n>>8));
  shiftOut(DATA, CLOCK, MSBFIRST, (n));
  digitalWrite(LATCH, HIGH);
  delay(1);
  digitalWrite(LATCH, LOW);
}

void initLED() {
  ledOut(0x0B07);
  ledOut(0x0A0C);
  ledOut(0x0900);
  ledOut(0x0C01);
}

void clearLED() {
  for (int i=0;i<8;i++) {
    matrix[i] = 0x00;
  }
  refreshLED();
}

void refreshLED() {
  int n1, n2, n3;
  for (int i=0;i<8;i++) {
    n1 = i+1;
    n2 = matrix[i];
    n3 = (n1<<8)+n2;
    ledOut(n3);
  }
}

void updateLED(int i, int j, boolean b) {
  int t = 1;
  int n = 0;
  int m = 0;
  if (j==0) {
    m = 7;
  }
  else {
    m = j-1;
  }
  n = t<<m;
  if (b) {
    matrix[i] = n | matrix[i];
  }
  else {
    n = ~n;
    matrix[i] = n & matrix[i];
  }
}
\$\endgroup\$
2
\$\begingroup\$

Sorry if it's a bit late for you, but I've just written a post about using the MAX7219 with LED matrices and 7-segment LED Displays.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.