Este es el código.
int clockPin = 2; //BLUE
int latchPin = 3; //GREEN
int dataPin = 4; //Yellow
int clockPinx = 5; //BLUE
int latchPinx = 6; //GREEN
int dataPinx = 7; //ORANGE
/*////////////////////////////////////////////////////////////////////////////////
* Arduino code to display scrolling characters on 6 or more 8x8 LED matrix. *
* The no: of matrices can be increased with a small change in code. *
* Circuit designed and program coded by PALLAB SARKAR *
* Instagram : _its_015
* Facebook : Pallab Sarkar
/*////////////////////////////////////////////////////////////////////////////////
char msg[] ="/ HELLO / ";//Change the text here.
int scrollspeed=15;//Set the scroll speed ( lower=faster)
int x;
int y;
//Columns
int clockPin1 = 2; //Arduino pin connected to Clock Pin 11 of 74HC595
int latchPin1 = 3; //Arduino pin connected to Latch Pin 12 of 74HC595
int dataPin1 = 4; //Arduino pin connected to Data Pin 14 of 74HC595
//Rows
int clockPin2 = 5; //Arduino pin connected to Clock Pin 11 of 74HC595
int latchPin2 = 6; //Arduino pin connected to Latch Pin 12 of 74HC595
int dataPin2 = 7; //Arduino pin connected to Data Pin 14 of 74HC595
//BITMAP
//Bits in this array represents one LED of the matrix
// 8 is # of rows, 6 is # of LED matrices
byte bitmap[8][4];
int numZones = sizeof(bitmap) / 8; // One Zone refers to one 8 x 8 Matrix ( Group of 8 columns)
int maxZoneIndex = numZones-1;
int numCols = numZones * 8;
//FONT DEFENITION
byte alphabets[][8] = {
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, /*space*/
{0x2a,0x1c,0x3e,0x1c,0x2a,0x00,0x00,0x00}, /***/
{0x08,0x08,0x3e,0x08,0x08,0x00,0x00,0x00}, /*+*/
{0x00,0x0d,0x0e,0x00,0x00,0x00,0x00,0x00}, /*,*/
{0x08,0x08,0x08,0x08,0x08,0x00,0x00,0x00}, /*-*/
{0x00,0x06,0x06,0x00,0x00,0x00,0x00,0x00}, /*.*/
{0x03,0x04,0x08,0x10,0x60,0x00,0x00,0x00}, /*/*/
{0x3e,0x45,0x49,0x51,0x3e,0x00,0x00,0x00}, /*0*/
{0x00,0x21,0x7f,0x01,0x00,0x00,0x00,0x00}, /*1*/
{0x31,0x43,0x45,0x49,0x31,0x00,0x00,0x00}, /*2*/
{0x22,0x41,0x49,0x49,0x36,0x00,0x00,0x00}, /*3*/
{0x08,0x18,0x28,0x7f,0x08,0x00,0x00,0x00}, /*4*/
{0x72,0x51,0x51,0x51,0x4e,0x00,0x00,0x00}, /*5*/
{0x3e,0x49,0x49,0x49,0x26,0x00,0x00,0x00}, /*6*/
{0x60,0x40,0x47,0x48,0x70,0x00,0x00,0x00}, /*7*/
{0x36,0x49,0x49,0x49,0x36,0x00,0x00,0x00}, /*8*/
{0x32,0x49,0x49,0x49,0x3e,0x00,0x00,0x00}, /*9*/
{0x00,0x63,0x63,0x00,0x00,0x00,0x00,0x00}, /*:*/
{0x00,0x6d,0x6e,0x00,0x00,0x00,0x00,0x00}, /*;*/
{0x08,0x14,0x22,0x00,0x00,0x00,0x00,0x00}, /*<*/
{0x14,0x14,0x14,0x14,0x14,0x00,0x00,0x00}, /*=*/
{0x00,0x22,0x14,0x08,0x00,0x00,0x00,0x00}, /*>*/
{0x60,0x80,0x8d,0x90,0x60,0x00,0x00,0x00}, /*?*/
{0x3e,0x41,0x5d,0x5d,0x38,0x00,0x00,0x00}, /*@*/
{0x3f,0x48,0x48,0x48,0x3f,0x00,0x00,0x00}, /*A*/
{0x7f,0x49,0x49,0x49,0x36,0x00,0x00,0x00}, /*B*/
{0x3e,0x41,0x41,0x41,0x22,0x00,0x00,0x00}, /*C*/
{0x7f,0x41,0x41,0x41,0x3e,0x00,0x00,0x00}, /*D*/
{0x7f,0x49,0x49,0x49,0x41,0x00,0x00,0x00}, /*E*/
{0x7f,0x48,0x48,0x48,0x40,0x00,0x00,0x00}, /*F*/
{0x3e,0x41,0x41,0x45,0x26,0x00,0x00,0x00}, /*G*/
{0x7f,0x08,0x08,0x08,0x7f,0x00,0x00,0x00}, /*H*/
{0x41,0x41,0x7f,0x41,0x41,0x00,0x00,0x00}, /*I*/
{0x46,0x41,0x41,0x41,0x7e,0x00,0x00,0x00}, /*J*/
{0x7f,0x08,0x14,0x22,0x41,0x00,0x00,0x00}, /*K*/
{0x7f,0x01,0x01,0x01,0x01,0x00,0x00,0x00}, /*L*/
{0x7f,0x20,0x18,0x20,0x7f,0x00,0x00,0x00}, /*M*/
{0x7f,0x10,0x08,0x04,0x7f,0x00,0x00,0x00}, /*N*/
{0x3e,0x41,0x41,0x41,0x3e,0x00,0x00,0x00}, /*O*/
{0x7f,0x48,0x48,0x48,0x30,0x00,0x00,0x00}, /*P*/
{0x3e,0x41,0x45,0x43,0x3f,0x00,0x00,0x00}, /*Q*/
{0x7f,0x48,0x4c,0x4a,0x31,0x00,0x00,0x00}, /*R*/
{0x32,0x49,0x49,0x49,0x26,0x00,0x00,0x00}, /*S*/
{0x60,0x40,0x7f,0x40,0x60,0x00,0x00,0x00}, /*T*/
{0x7e,0x01,0x01,0x01,0x7e,0x00,0x00,0x00}, /*U*/
{0x7c,0x02,0x01,0x02,0x7c,0x00,0x00,0x00}, /*V*/
{0x7e,0x01,0x0e,0x01,0x7e,0x00,0x00,0x00}, /*W*/
{0x63,0x14,0x08,0x14,0x63,0x00,0x00,0x00}, /*X*/
{0x60,0x10,0x0f,0x10,0x60,0x00,0x00,0x00}, /*Y*/
{0x43,0x45,0x49,0x51,0x61,0x00,0x00,0x00}, /*Z*/
{0x7f,0x41,0x00,0x00,0x00,0x00,0x00,0x00}, /*[*/
{0x3e,0x41,0x41,0x00,0x00,0x00,0x00,0x00}, /*<*/
{0x41,0x7f,0x00,0x00,0x00,0x00,0x00,0x00}, /*]*/
{0x08,0x10,0x20,0x10,0x08,0x00,0x00,0x00}, /*^*/
{0x02,0x02,0x02,0x02,0x02,0x00,0x00,0x00}, /*_*/
{0x00,0x00,0x70,0x78,0x08,0x00,0x00,0x00}, /*`*/
{0x02,0x15,0x15,0x15,0x0f,0x00,0x00,0x00}, /*a*/
{0x7f,0x09,0x11,0x11,0x0e,0x00,0x00,0x00}, /*b*/
{0x0e,0x11,0x11,0x11,0x00,0x00,0x00,0x00}, /*c*/
{0x0e,0x11,0x11,0x09,0x7e,0x00,0x00,0x00}, /*d*/
{0x0e,0x15,0x15,0x15,0x0c,0x00,0x00,0x00}, /*e*/
{0x08,0x3f,0x48,0x40,0x20,0x00,0x00,0x00}, /*f*/
{0x18,0x25,0x25,0x25,0x1e,0x00,0x00,0x00}, /*g*/
{0x7f,0x08,0x10,0x10,0x0f,0x00,0x00,0x00}, /*h*/
{0x00,0x05,0x2f,0x01,0x00,0x00,0x00,0x00}, /*i*/
{0x02,0x09,0x2f,0x08,0x00,0x00,0x00,0x00}, /*j*/
{0x7f,0x04,0x0a,0x11,0x00,0x00,0x00,0x00}, /*k*/
{0x00,0x41,0x7f,0x01,0x00,0x00,0x00,0x00}, /*l*/
{0x1f,0x10,0x08,0x10,0x0f,0x00,0x00,0x00}, /*m*/
{0x1f,0x10,0x10,0x10,0x0f,0x00,0x00,0x00}, /*n*/
{0x0e,0x11,0x11,0x11,0x0e,0x00,0x00,0x00}, /*o*/
{0x1f,0x14,0x14,0x14,0x08,0x00,0x00,0x00}, /*p*/
{0x08,0x14,0x14,0x1f,0x01,0x00,0x00,0x00}, /*q*/
{0x1f,0x08,0x10,0x10,0x08,0x00,0x00,0x00}, /*r*/
{0x09,0x15,0x15,0x15,0x12,0x00,0x00,0x00}, /*s*/
{0x08,0x3e,0x09,0x01,0x02,0x00,0x00,0x00}, /*t*/
{0x1e,0x01,0x01,0x01,0x1f,0x00,0x00,0x00}, /*u*/
{0x1c,0x02,0x01,0x02,0x1c,0x00,0x00,0x00}, /*v*/
{0x1f,0x02,0x0c,0x02,0x1f,0x00,0x00,0x00}, /*w*/
{0x11,0x0a,0x04,0x0a,0x11,0x00,0x00,0x00}, /*x*/
{0x18,0x05,0x05,0x05,0x1e,0x00,0x00,0x00}, /*y*/
{0x11,0x13,0x15,0x19,0x00,0x00,0x00,0x00}, /*z*/
{0x08,0x36,0x41,0x41,0x00,0x00,0x00,0x00}, /*{*/
{0x00,0x00,0x7f,0x00,0x00,0x00,0x00,0x00}, /*|*/
{0x00,0x41,0x41,0x36,0x08,0x00,0x00,0x00}, /*}*/
{0x08,0x10,0x08,0x04,0x08,0x00,0x00,0x00}, /*~*/
{0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00},
};
void setup() {
pinMode(latchPin1, OUTPUT);
pinMode(clockPin1, OUTPUT);
pinMode(dataPin1, OUTPUT);
pinMode(latchPin2, OUTPUT);
pinMode(clockPin2, OUTPUT);
pinMode(dataPin2, OUTPUT);
//Clear bitmap
for (int row = 0; row < 8; row++) {
for (int zone = 0; zone <= maxZoneIndex; zone++) {
bitmap[row][zone] = 0;
}
}
}
//FUNCTIONS
// Displays bitmap array in the matrix
void RefreshDisplay()
{
for (int row = 0; row < 8; row++) {
int rowbit = 1 << row;
digitalWrite(latchPin2, LOW);//Hold latchPin LOW for transmitting data
shiftOut(dataPin2, clockPin2, MSBFIRST, rowbit); //Transmit data
//Start sending column bytes
digitalWrite(latchPin1, LOW);//Hold latchPin LOW for transmitting data
//Shift out to each matrix
for (int zone = maxZoneIndex; zone >= 0; zone--)
{
shiftOut(dataPin1, clockPin1, MSBFIRST, bitmap[row][zone]);
}
//flip both latches at once to eliminate flicker
digitalWrite(latchPin1, HIGH);//Return the latch pin 1 high to signal chip
digitalWrite(latchPin2, HIGH);//Return the latch pin 2 high to signal chip
//Wait
delayMicroseconds(100);
}
}
// Converts row and colum to bitmap bit and turn it off/on
void Plot(int col, int row, bool isOn)
{
int zone = col / 8;
int colBitIndex = x % 8;
byte colBit = 1 << colBitIndex;
if (isOn)
bitmap[row][zone] = bitmap[y][zone] | colBit;
else
bitmap[row][zone] = bitmap[y][zone] & (~colBit);
}
// Plot each character of the message one column at a time, updated the display, shift bitmap left.
void XProcess()
{
for (int charIndex=0; charIndex < (sizeof(msg)-1); charIndex++)
{
int alphabetIndex = msg[charIndex] -')';
if (alphabetIndex < 0) alphabetIndex=0;
//Draw one character of the message
// Each character is 5 columns wide, loop two more times to create 2 pixel space betwen characters
for (int col = 0; col < 6; col++)
{
for (int row = 0; row < 8; row++)
{
// Set the pixel to what the alphabet say for columns 0 thru 4, but always leave columns 5 and 6 blank.
bool isOn = 0;
if (col<5) isOn = bitRead( alphabets[alphabetIndex][col], 7-row ) == 1;
Plot( numCols-1, row, isOn); //Draw on the rightmost column, the shift loop below will scroll it leftward.
}
for (int refreshCount=0; refreshCount < scrollspeed; refreshCount++)
RefreshDisplay();
//Shift the bitmap one column to left
for (int row=0; row<8; row++)
{
for (int zone=0; zone < numZones; zone++)
{
//This right shift would show as a left scroll on display because leftmost column is represented by least significant bit of the byte.
bitmap[row][zone] = bitmap[row][zone] >> 1;
// Shift over lowest bit from the next zone as highest bit of this zone.
if (zone < maxZoneIndex) bitWrite(bitmap[row][zone], 7, bitRead(bitmap[row][zone+1],0));
}
}
}
}
}
void loop() {
XProcess();
}