## "HELLO..." in an 8*8 LED Matrix Using Arduino Mega and 74595 Shift Register

by realfinetime  |  in LED Matrix at  06:17

We had already seen the circuit to connect 8*8 LED matrix to arduino through 8 bit shift register IC 74595 in previous blog. Complete the circuit as given in this page. Next is a program to display 'HELLO...' in 8*8 LED matrix. LED matrix will look like as shown in the following image.

```int latchPin = 12;  //Pin connected to ST_CP of 1st 74595
int clockPin = 13;  //Pin connected to SH_CP of 1st 74595
int dataPin = 11;   //Pin connected to DS of 1st 74595

int latchPin2 = 6;  //Pin connected to ST_CP of 2nd 74595
int clockPin2 = 7;  //Pin connected to SH_CP of 2nd 74595
int dataPin2 = 5;   //Pin connected to DS of 2nd 74595

int i=0,j=0,k=0,length_of_cathode_decimal_array;
int anode_decimal[]={1, 2, 4, 8, 16, 32, 64, 128};
int cathode_decimal[]={0, 0, 231, 231, 231, 231, 0, 0, 255, //Display 'H'
0, 0, 36, 36, 36, 36, 36, 36, 36, 36, 255, //Display 'E'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 60, 60, 60, 60, 60, 0, 0,    //Display 'O'
255, 127, 255, 127, 255, 127, 255}; //Display '...'

void setup() {
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);

pinMode(latchPin2, OUTPUT);
pinMode(clockPin2, OUTPUT);
pinMode(dataPin2, OUTPUT);
}

void loop() {

int temp;
for(k=0;k<6;k++) // To give a time delay to illumination
{
/** To access individual elements of 'anode_decimal' and 'cathode_decimal' arrays **/
for(j=0;j<8;j++)
{
/************To increase the ON time of LEDs five times more than
OFF time to increase the brightness of LEDs*************/
for(i=0;i<5;i++)
{

// take the latchPin low so the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, anode_decimal[j]);
// shift out the bits:
digitalWrite(latchPin, HIGH);

// take the latchPin low so the LEDs don't change while you're sending in bits:
digitalWrite(latchPin2, LOW);
shiftOut(dataPin2, clockPin2, MSBFIRST, cathode_decimal[j]);
// shift out the bits:
digitalWrite(latchPin2, HIGH);
}

/**************************  TURN OFF ALL LEDs  ***************************/

/*** Send LOW to all Anode pins (16, 15, 11, 3, 10, 5, 6, 13) of LED matrix ***/

// take the latchPin low so the LEDs don't change while you're sending in bits:
digitalWrite(latchPin, LOW);
//Send 0 0 0 0 0 0 0 0 (1) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
shiftOut(dataPin, clockPin, MSBFIRST, 0);
// shift out the bits:
digitalWrite(latchPin, HIGH);

/*** Send HIGH to all cathode pins (4, 7, 2, 8, 12, 1, 14 and 9) of LED matrix ***/

// take the latchPin low so the LEDs don't change while you're sending in bits:
digitalWrite(latchPin2, LOW);
//Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
// shift out the bits:
digitalWrite(latchPin2, HIGH);
}
}

/*** ROTATE THE 'cathode_decimal' ARRAY ONE POSITION TOWARDS LEFT SIDE *****/

// Get the length of cathode_decimal array
length_of_cathode_decimal_array = sizeof(cathode_decimal)/sizeof(cathode_decimal[0]);

// Copy the first element of array to 'temp'.
temp=cathode_decimal[0];

/**** Shift all the elements of cathode_decimal array, other than first element,
one position towards left ****/
for(i=1;i<length_of_cathode_decimal_array;i++)
{
cathode_decimal[i-1]=cathode_decimal[i];
}

/**** Copy the value in 'temp' to last position of 'cathode_decimal' array.
Then first element in old array becomes last element in new array ****/
cathode_decimal[length_of_cathode_decimal_array-1]=temp;
}
```

If uploading is successful, 'HELLO...' will start running on 8*8 LED matrix. Algorithm of program is clearly explained in my previous post about simple trick to design an amazing illumination in 8*8 LED matrix. Repeating the same again is not fair. Speed of display can be adjusted by changing the upper limit of 'k' loop. 'j' loop is for accessing individual elements in each array. 'i' loop is for adjusting the brightness of  LEDs. 'cathode_element' array should have more than eight elements. Otherwise, 'j' loop will give an error.

1. Gracias por el aporte y conocimientos, podrias por favor explicarme el desplazamiento de las letras no comprendo por favor

Gracias

2. Not working properly.

3. can anyone explain me........ int i=0,j=0,k=0,length_of_cathode_decimal_array;
int anode_decimal[]={1, 2, 4, 8, 16, 32, 64, 128};
int cathode_decimal[]={0, 0, 231, 231, 231, 231, 0, 0, 255, //Display 'H'
0, 0, 36, 36, 36, 36, 36, 36, 36, 36, 255, //Display 'E'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 60, 60, 60, 60, 60, 0, 0, //Display 'O'
255, 127, 255, 127, 255, 127, 255}; //Display '...'

1. please mention where you facing problems.
thank you

4. I want to write A,to,Z.....But i can't Write....Plz any one tell Me...
int i=0,j=0,k=0,length_of_cathode_decimal_array;
int anode_decimal[]={1, 2, 4, 8, 16, 32, 64, 128};
int cathode_decimal[]={0, 0, 231, 231, 231, 231, 0, 0, 255, //Display 'H'
0, 0, 36, 36, 36, 36, 36, 36, 36, 36, 255, //Display 'E'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 60, 60, 60, 60, 60, 0, 0, //Display 'O'
255, 127, 255, 127, 255, 127, 255}; //Display '...'

1. Same problem here

5. I WANT TO WRITE A TO Z BUT I CANT PLS HELP FOR KEYWORDS.>>
can anyone explain me........ int i=0,j=0,k=0,length_of_cathode_decimal_array;
int anode_decimal[]={1, 2, 4, 8, 16, 32, 64, 128};
int cathode_decimal[]={0, 0, 231, 231, 231, 231, 0, 0, 255, //Display 'H'
0, 0, 36, 36, 36, 36, 36, 36, 36, 36, 255, //Display 'E'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 63, 63, 63, 63, 63, 63, 255, //Display 'L'
0, 0, 60, 60, 60, 60, 60, 0, 0, //Display 'O'
255, 127, 255, 127, 255, 127, 255}; //Display '...'

## IMPORTANT NOTICE

All the circuits, published in this blog is only after testing and getting proper results in my private lab. When you try these circuits, you should check the supply voltage, polarity of components, presence of childrens nearby and shorts in the circuits. This website will not be responsible for any harm happened to you or your components caused by your carelessness.