Pages: [1]   Go Down
Author Topic: control 2*8x8 LED matrix by 3*74HC595N  (Read 1036 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 6
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I used three 74HC595N to control two 8x8 LED matrix and its work. For more, I would like to expend the  LED from 2 to 10, like a 80x8 LED stick. So that, I had been tried to expend my program from 2 to 10. However, I discovered that the frequency of LED is too low which occurred flashing but the delay time going to the lowest - 30us(not work if lower that 30us). How can I fix it?


Here is the code before change:

Quote
int latchPin1 = 2;
int clockPin1 = 4;
int dataPin1 = 3;
int latchPin2 = 5;
int clockPin2 = 7;
int dataPin2 = 6;
int words[3][5]={
  {124,18,17,18,124},
  {127,73,73,73,54},
  {62,65,65,65,34}
};
char msg[] = "ABCCBA";
int length;
int i;
int j;
int k=0;
int get;
int msgCode[20];
int msgCode2[120];

void setup() {
  Serial.begin(9600);
  get=msg[0];
  while(get!=0) {
    get=msg;
    if(get==0) {
      length=i;
      Serial.print(length);
      Serial.print("\n");
      break;
    }
    msgCode=get;
    Serial.print(msgCode);
    Serial.print(" = ");
    for(int j=0; j<=4; j++) {
      msgCode2[i*6+j]=words[msgCode-65][j];
      Serial.print(msgCode2[i*6+j]);
      Serial.print(", ");
    }
    i++;
    msgCode2[i*6-1]=0;
    Serial.print(msgCode2[i*6-1]);
    Serial.print("\n");
  }
  for(int i=0; i<=length*6-1; i++) {
    Serial.print(msgCode2);
    Serial.print(", ");
  }
  for(int i=0; i<=7; i++) {
    msgCode2[length*6+i]=0;
  }
  length+=1;
  int massageCode[]={124,18,17,18,124};
  pinMode(latchPin1, OUTPUT);
  pinMode(clockPin1, OUTPUT);
  pinMode(dataPin1, OUTPUT);
  pinMode(latchPin2, OUTPUT);
  pinMode(clockPin2, OUTPUT);
  pinMode(dataPin2, OUTPUT);
}

void loop() {
  for(int j=0; j<=7; j++) {
    digitalWrite(latchPin1, LOW);
    digitalWrite(latchPin2, LOW);
    shiftOut(dataPin1, clockPin1, MSBFIRST, msgCode2[j]);//data per column
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 2
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255-(1<<j));//display some pattern in LED matrix 1
    digitalWrite(latchPin1, HIGH);
    digitalWrite(latchPin2, HIGH);
    delayMicroseconds(500);
  }
  for(int j=0; j<=7; j++) {
    digitalWrite(latchPin1, LOW);
    digitalWrite(latchPin2, LOW);
    shiftOut(dataPin1, clockPin1, MSBFIRST, msgCode2[j+8]);//data per column
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255-(1<<j));//display some pattern in LED matrix 2
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 1
    digitalWrite(latchPin1, HIGH);
    digitalWrite(latchPin2, HIGH);
    delayMicroseconds(500);
  }
  k++;
  if(k==20) {
    int msgCode3=msgCode2[0];
    for(int l=0; l<=length*6-2; l++) {
      msgCode2[l]=msgCode2[l+1];
    }
    msgCode2[length*6-1]=msgCode3;
    k=0;
  }
}


How about 10 LED matrix? This is the display command for last LED matrix only! It will be lag if copy and paste it 10 times:
Quote
 for(int j=0; j<=7; j++) {
    digitalWrite(latchPin1, LOW);
    digitalWrite(latchPin2, LOW);
    shiftOut(dataPin1, clockPin1, MSBFIRST, msgCode2[j+8]);//data per column
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255-(1<<j));//display some pattern in LED matrix 10
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 9
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 8
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 7
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 6
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 5
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 4
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 3
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 2
    shiftOut(dataPin2, clockPin2, MSBFIRST, 255);//display blank in LED matrix 1
    digitalWrite(latchPin1, HIGH);
    digitalWrite(latchPin2, HIGH);
    delayMicroseconds(30);
  }
« Last Edit: November 14, 2011, 01:25:22 am by x850xtpe » Logged

Florida
Offline Offline
Sr. Member
****
Karma: 4
Posts: 431
hookedup!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Use SPI instead of shiftOut.

This post may help...
http://arduino.cc/forum/index.php?topic=38155.0;wap2

Logged

Pages: [1]   Go Up
Jump to: