Sorry OB. I know you would rather I hadn’t posted this.
/* ****************************************************************************
LEDmatrix.ino
I made this. Freely donated to the community. I take no responsibility for
harm caused by this program, but will happily accept credit for any good that
comes of it.
*******************************************************************************/
#include <avr/pgmspace.h>
// Pin configuration for Arduino Uno
const int runLamp = 13;
const int R8 = 12; // rows
const int R7 = 11;
const int R6 = 10;
const int R5 = 9;
const int R4 = 8;
const int R3 = 7;
const int R2 = 6;
const int R1 = 5;
const int C8 = 4; // columns
const int C7 = 3;
const int C6 = 2;
const int C5 = A5;
const int C4 = A4;
const int C3 = A3;
const int C2 = A2;
const int C1 = A1;
// Software Constants
const int rowPin[8] = {R1,R2,R3,R4,R5,R6,R7,R8};
const int colPin[8] = {C1,C2,C3,C4,C5,C6,C7,C8};
// Font
prog_uchar font[760] PROGMEM = {
0,0,0,0,0,0,0,0,12,12,12,12,0,12,12,0,20,20,20,0,0,0,0,0,76,254,76,76,254,76,76,0,
60,86,22,60,80,86,60,0,102,110,12,24,48,118,102,0,28,38,54,12,86,38,92,0,8,8,8,0,0,0,0,0,
8,4,6,6,6,6,4,8,16,32,96,96,96,96,32,16,8,42,28,8,28,42,8,0,0,8,8,62,8,8,0,0,
0,0,0,0,0,12,12,2,0,0,0,62,0,0,0,0,0,0,0,0,0,12,12,0,32,32,16,8,4,2,2,0,
28,38,54,46,38,38,28,0,24,28,28,24,24,24,24,0,28,38,32,24,4,6,62,0,28,38,32,24,32,38,28,0,
44,44,38,38,62,32,32,0,62,6,30,32,32,38,28,0,28,38,6,30,38,38,28,0,62,32,16,8,8,4,4,0,28,38,38,28,38,38,28,0,
28,38,38,60,32,32,28,0,0,0,12,12,0,12,12,0,0,0,12,12,0,12,12,2,32,16,8,4,8,16,32,0,
0,0,62,0,62,0,0,0,4,8,16,32,16,8,4,0,12,18,16,12,0,12,12,0,62,65,89,85,57,65,62,0,
60,70,70,126,70,70,70,0,62,70,70,62,70,70,62,0,60,70,6,6,6,70,60,0,30,38,70,70,70,38,30,0,
126,6,6,30,6,6,126,0,126,6,6,62,6,6,6,0,60,70,6,6,118,70,60,0,70,70,70,126,70,70,70,0,
126,24,24,24,24,24,126,0,126,24,24,24,24,8,6,0,70,38,22,14,22,38,70,0,6,6,6,6,6,6,126,0,
70,110,86,70,70,70,70,0,70,78,86,86,102,70,70,0,60,70,70,70,70,70,60,0,62,70,70,62,6,6,6,0,
60,70,70,70,86,38,92,0,62,70,70,62,70,70,70,0,60,70,6,60,64,70,60,0,126,24,24,24,24,24,24,0,
70,70,70,70,70,70,60,0,70,70,70,44,44,24,24,0,70,70,70,70,70,86,44,0,70,46,44,24,52,116,98,0,
70,70,44,24,24,24,24,0,126,96,48,24,12,6,126,0,60,12,12,12,12,12,60,0,2,2,4,8,16,32,32,0,
60,48,48,48,48,48,60,0,8,20,34,0,0,0,0,0,0,0,0,0,0,0,0,127,4,8,0,0,0,0,0,0,
0,0,12,16,28,18,28,0,2,2,2,14,18,18,14,0,0,0,0,12,2,2,12,0,16,16,16,28,18,18,28,0,
0,0,12,18,30,2,12,0,0,0,24,4,14,4,4,4,0,0,0,28,18,28,16,12,2,2,2,14,18,18,18,0,
0,0,4,0,4,4,4,0,0,0,4,0,4,4,4,2,2,2,2,10,6,10,10,0,2,2,2,2,2,2,4,0,
0,0,0,22,42,34,34,0,0,0,0,14,18,18,18,0,0,0,0,12,18,18,12,0,0,0,0,14,18,14,2,2,
0,0,0,28,18,28,16,16,0,0,0,26,6,2,2,0,0,0,28,2,12,16,14,0,0,4,4,14,4,4,24,0,
0,0,0,18,18,18,28,0,0,0,0,34,34,20,8,0,0,0,0,34,34,42,20,0,0,0,0,18,12,12,18,0,
0,0,0,18,18,28,16,12,0,0,0,30,8,4,30,0,16,8,8,4,8,8,16,0,8,8,8,8,8,8,8,0,
8,16,16,32,16,16,8,0,0,76,50,0,0,0,0,0
};
// Global Variables
boolean frame[8][8];
String msg = String(" BaseOverApex says “LETSMAKEROBOTS” ");
boolean runLampToggle = true;
int n; // index of the character within the string
int row; // index of a particular row of the font character
int col; // index of a particular column of the font character
int ch1, ch2; // ASCII value of current character - 32
word row16[8]; // all bis required for 2 charachers
void setup() {
for (int i=0;i<8;i++) {
pinMode(rowPin[i], OUTPUT);
pinMode(colPin[i], OUTPUT);
digitalWrite(colPin[i], HIGH);
digitalWrite(rowPin[i], LOW);
}
pinMode(runLamp, OUTPUT);
} // setup
void loop() {
for (n=0; n<msg.length()-1; n++) { // for each character in the string
digitalWrite(runLamp, runLampToggle);
runLampToggle = !runLampToggle;
// get current and next characters
ch1 = msg.charAt(n) - 32;
ch2 = msg.charAt(n + 1) - 32;
// compile array of 16-bit bytes corresponding to the bit patterns
// the current char and the next char
for (row=0; row<8; row++) {
row16[row] = pgm_read_byte_near(font + (ch1 8) + row)
+ (pgm_read_byte_near(font + (ch2 8) + row) << 8);
}
for (int scroll=0; scroll<8; scroll++) {
// for each of 8 columns, compile a byte representing the bit pattern
// for the column and transfer it into the frame buffer
for (col=0; col<8; col++) {
word mask = 1 << (col + scroll);
byte colByte = 0;
for (int row=0; row<8; row++) {
colByte += (1<<row) * (((row16[row] & mask) == 0) ? 0:1);
}
writeCol(col, colByte);
} // for col
// display it
for (int z=0; z<3; z++) {
refresh();
delay(10);
}
} // for scroll
} // for n
} // loop
void writeCol (int col, byte data) {
byte mask = 1;
for (int row=0; row<8; row++) {
frame[col][row] = data & mask; // sel col bit on
mask = mask << 1;
}
} // writeCol
void refresh() {
for (int x=0; x<8; x++) {
digitalWrite(colPin[x],true); // column off
for (int y=0; y<8; y++) {
digitalWrite(rowPin[y],frame[x][y]); // row bit on
}
digitalWrite(colPin[x],false); // column on
delay(2);
digitalWrite(colPin[x],true); // column off
}
} // refresh