Go Down

Topic: control 2*8x8 LED matrix by 3*74HC595N (Read 1 time) previous topic - next topic

x850xtpe

Nov 14, 2011, 07:10 am Last Edit: Nov 14, 2011, 07:25 am by x850xtpe Reason: 1
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);
 }

marklar

Use SPI instead of shiftOut.

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


Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy