8x8 LED Matrix

Hi guys!

I have a simple question for all of u.
I have 8x8 LED matrix which is pretty good because it has its own circuit. It has only 5 pins(VCC, GND, DIN, CS and CLK).
Now what I am askingx you, is: How to start this matrix and how to control it?
If you have work with 8x8 LED matrix like mine, please leave me an answer(with code please that i could learn from example).

TNX u all

WEB Link to the display please. SPI will probably work but we need more information.

It is just like this. I dont have link or information about my one. http://www.instructables.com/id/LED-Matrix-with-Arduino/?ALLSTEPS

On my one is written HL - M1388AR

It is just like this. I dont have link or information about my one. http://www.instructables.com/id/LED-Matrix-with-Arduino/?ALLSTEPS

Did you try this?

LarryD: Did you try this?

Yes, I tried this, but it is not working.

That Matrix is just an ordinary LED matrix with a MAX7219 attached to it. So any code that uses this chip will do. See:- http://playground.arduino.cc/Main/LEDMatrix

vitothelegend: Yes, I tried this, but it is not working.

You probably miss wired it or it is broken. Can you post a picture of your wiring ( not more than 1000 pixels wide )

Grumpy_Mike: That Matrix is just an ordinary LED matrix with a MAX7219 attached to it. So any code that uses this chip will do. See:- http://playground.arduino.cc/Main/LEDMatrix You probably miss wired it or it is broken. Can you post a picture of your wiring ( not more than 1000 pixels wide ) [/quote I am sorry, but i can not upload the image here. I can send it to your mail.

I am sorry, but i can not upload the image here.

Yes you can. Click on the reply box at the end of the last post. Then a box comes up to type your answer. At the lower left is a triangle saying additional options. That will allow you to attach a file, image files work very well.

Here is one picture. If you need more detailed, just say.

The thing is we need to see where the wires come from and go to.

It will also help if you post your code ( use code tags please ).

Here is the code with one picture.

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(10);
  for (int j=0;j<8;j++) {
    updateLED(idx, j, false);
  }
  refreshLED();
  delay(10);
  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(10);
  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];
  }
}

Picture was failed to load.

Finally.

That photo does not match up with the previous one. What pin have you got the clock connected to? I can't see where the ground goes. I can not see where the 5V goes.

I am supposed to be checking your circuit here can you check it from what you have posted?

That code is rubbish. It is using shift out for SPI operations. There is no latch pin on your device.

Every day some one gets in trouble following instructables crap. I am getting fed up of trying to act as their quality control.

Hi! VCC goes to 5V GND goes to GND DIN goes to 11 CS goes to 10 CLK goes to 12

That code you posted is rubbish because it does not initialise the internal registers. It also seems to be constantly refreshing the matrix which is not needed because that is what this chip does.

Your wiring does not match the wiring required for that library used in the instructables page you posted.

So I am very confused about what you are trying to do, perhaps even more confused that you are.

Way back in reply #5 I sent you a link to some reliable code to drive this chip. What have you done with this information? It uses different wiring than your posted (rubbish) code.

OK, here’s a test code for you (not at all to suggest that what Mike offered was not suitable):

/* Loop scanner demonstration
Code for max 7219 from maxim, reduced & optimised for using multiple 7219 cascaded.
______________________________________

General notes: 

- if using only one max7219, then use maxSingle function to control
the module --- maxSingle(register (1-8), column (0-255))

- if using more then one max7219, and all should work the same, use maxAll
function --- maxAll(register (1-8), collum (0-255))

- if using more than one max7219 and want to change something on one module only,
then use maxOne function 
--- maxOne(module you want to control [1=first], register [1-8], column [0-255])

 During initiation, be sure to send every part to every max7219 and then upload it.
For example, if you have five max7219's, you have to send the scanLimit 5 times
before you load it, otherwise not every max7219 will get the data. the (fixed)
variable maxInUse keeps track of this, just tell it how many max7219 you are using.
*/

int dataIn = 11;            // "DIN" on module
int load = 10;              // "CS" on module
int clock = 12;             // "CLK" on module
const int ledPin =  13;    // LED pin number

int maxInUse = 1;          // set how many MAX7219's used
int ledState = LOW;        // initialise the LED

int e = 0;                 // just a varialble

// define max7219 registers
byte max7219_reg_noop        = 0x00;
byte max7219_reg_digit0      = 0x01;
byte max7219_reg_digit1      = 0x02;
byte max7219_reg_digit2      = 0x03;
byte max7219_reg_digit3      = 0x04;
byte max7219_reg_digit4      = 0x05;
byte max7219_reg_digit5      = 0x06;
byte max7219_reg_digit6      = 0x07;
byte max7219_reg_digit7      = 0x08;
byte max7219_reg_decodeMode  = 0x09;
byte max7219_reg_intensity   = 0x0a;
byte max7219_reg_scanLimit   = 0x0b;
byte max7219_reg_shutdown    = 0x0c;
byte max7219_reg_displayTest = 0x0f;


void putByte(byte data) {
  byte i = 8;
  byte mask;
  while(i > 0) {
    mask = 0x01 << (i - 1);      // get bitmask
    digitalWrite( clock, LOW);   // tick
    if (data & mask) {           // choose bit
      digitalWrite(dataIn, HIGH);// send 1
    } else {
      digitalWrite(dataIn, LOW); // send 0
    }
    digitalWrite(clock, HIGH);   // tock
    --i;                         // move to lesser bit
  }
}

// maxSingle is the "easy" function to use for a single max7219
void maxSingle( byte reg, byte col) {    
  digitalWrite(load, LOW);  // begin     
  putByte(reg);             // specify register
  putByte(col);             //((data & 0x01) * 256) + data >> 1); // put data   
  digitalWrite(load,HIGH); 
}

// initialize all MAX7219's
void maxAll( byte reg, byte col) {
  int c = 0;
  digitalWrite(load, LOW);
  for ( c =1; c<= maxInUse; c++) {
  putByte(reg);             // specify register
  putByte(col);             //((data & 0x01) * 256) + data >> 1); // put data
    }
  digitalWrite(load,HIGH);
}

// for adressing different MAX7219's while cascaded
void maxOne(byte maxNr, byte reg, byte col) {    
  int c = 0;
  digitalWrite(load, LOW);  // begin     
  for ( c = maxInUse; c > maxNr; c--) {
    putByte(0);             // no operation
    putByte(0);             // no operation
  }

  putByte(reg);             // specify register
  putByte(col);             //((data & 0x01) * 256) + data >> 1); // put data 

  for ( c = maxNr-1; c >= 1; c--) {
    putByte(0);             // no operation
    putByte(0);             // no operation
  }
  digitalWrite(load,HIGH); 
}

void putCol( byte colno, byte coldat) {
// Interprets colno as (zero ref) index in combined array
    byte t;
    t = colno >> 3;
    byte u;
    u = colno & 0x07;
    maxOne(t+1, u+1, coldat);
}


void dispon() {
 maxAll(max7219_reg_shutdown, 0x01);               // Display on
}  

void dispoff() {
 maxAll(max7219_reg_shutdown, 0x00);              // Display off
}  

byte irow = 0;          // Row index
byte icol = 0;          // Column index
byte pattern;           // bit mask
byte lcol;              // left border
byte rcol;              // right border
byte trow;              // top row marker
byte brow;              // bottom row marker

int s_vert;             // Vertical switch
int s_horz;             // Horizontal switch

void worker () {

  if (pattern == 0) pattern = trow;            // pattern must be set
  if (s_vert != 0) {
    if (s_vert == -1) {                     // moving upward
      pattern = pattern >> 1;
      if (pattern == trow) {                   // hit the top
        s_vert = 0; s_horz = 1;
      }
    } else {
      pattern = pattern << 1;               // moving downward
      if (pattern == brow) {                // hit the bottom
        s_vert = 0; s_horz = -1;
      }
    }
    putCol(icol,pattern);              // Show the column.
    return;
  }

  if (s_horz != 0) {
    putCol(icol,0);                    // blank previous column.
    if (s_horz == -1) {                     // moving left
      icol--;
      if (icol == lcol) {                      // hit the side
        s_horz = 0; s_vert = -1;
      }
    } else {
      icol++;                               // moving right
      if (icol == rcol) {                      // hit the side
        s_horz = 0; s_vert = 1;
      }
    }
    putCol(icol,pattern);              // Show the column.
  }
 }
  
// the follow variable is a long because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long interval = 60;           // interval at which to step (milliseconds)
long previousMillis = 0;      // will store last time LED was updated


void setup () {

  pinMode(dataIn, OUTPUT);
  pinMode(clock,  OUTPUT);
  pinMode(load,   OUTPUT);
  pinMode(ledPin, OUTPUT);      

  //Serial begin(9600);
  digitalWrite(13, HIGH);  

//initiation of the max 7219
  maxAll(max7219_reg_displayTest, 0x00); // no display test
  maxAll(max7219_reg_scanLimit, 0x07);   // all columns in use   
  maxAll(max7219_reg_decodeMode, 0x00);  // using a LED matrix (not digits)
  maxAll(max7219_reg_shutdown, 0x01);    // not in shutdown mode
  for (e=1; e<=8; e++) {                 // empty registers, turn all LEDs off 
    maxAll(e,0);
  }
  maxAll(max7219_reg_intensity, 0x08 & 0x0f);  // middle argument is intensity value
                                               // range: 0x00 to 0x0f
                                                 
  pattern = 0;
  s_vert = 0;
  s_horz = 1;

// define edges of loop
  lcol = 1;              // left border
  rcol = 6;              // right border
  trow = 0x02;           // top row marker
  brow = 0x40;           // bottom row marker      
      
}  

void loop () {

  unsigned long currentMillis = millis();
 
// Active waiting for next event
  if(currentMillis - previousMillis > interval) {
    // save the last time you blinked the LED 
    previousMillis = currentMillis;   

    // if the LED is off turn it on and vice-versa:
    if (ledState == LOW) { ledState = HIGH;  } else { ledState = LOW; }
    // Timed process:
    
    worker();

    // set the LED according to ledState:
    digitalWrite(ledPin, ledState);
    }

}