#include "letters.h"
#include <EEPROM.h>
//Defines column pins
#define C0 22
#define C1 23
#define C2 24
#define C3 25
#define C4 26
#define C5 27
#define C6 28
#define C7 29
//Defines row pins
#define R0 32
#define R1 33
#define R2 34
#define R3 35
#define R4 36
#define R5 37
#define R6 38
#define R7 39
String toPrint = "zach"; //Sets the text to be printed
char wordChar[4]; //Creates a character array to store the characters
int printLen = 0;
const int rows[] = { //Creates an array of the rows
R0, R1, R2, R3, R4, R5, R6, R7
};
const int cols[] = { //Creates an array of the columns
C0, C1, C2, C3, C4, C5, C6, C7
};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
for(int i = 0; i < 8; i++) { //Sets all of the pins to output
pinMode(rows[i], OUTPUT);
pinMode(cols[i], OUTPUT);
}
clearMatrix(); //Clears the leds
for (int i = 0; i < toPrint.length(); i++) { //Writes the characters to the array
wordChar[i] = toPrint.charAt(i);
}
printLen = toPrint.length();
}
void loop() {
int letterIndex;
for (int letterStep = 0; letterStep < printLen; letterStep++) { //Steps through each letter
char let = wordChar[letterStep]; //Sets the character next being displayed
for (int i = 0; i < 26; i++) { //Checks the letter against each entry in the alphabet array
if (letterArray[i] == let) {
letterIndex = i;
break;
}
if (i == 25) { //Non numeric character
letterIndex = 26;
}
}
for (int offset = -6; offset < 6; offset++) { //Sets the offset
for (int column = 0; column < 8; column++) { //Steps through each column
if (offset + column <= 8 && offset + column >= 0) { //Checks if indicies are within the correct range
for (int row = 0; row < 8; row++) { //Steps through each row in the column
digitalWrite(rows[row], library_display[letterIndex][row][column + offset]); //turns on if the character table is 1
}
}
digitalWrite(cols[column], LOW); //Sets the column targeted to low
delay(1); //delay to breifly flash the led on
digitalWrite(cols[column], HIGH); //Sets the column targeted to high
}
clearMatrix(); // clear matrix
delay(100); //waits 100ms before drawing the next frame
}
}
}
void clearMatrix() { //Clears the matrix
for(int i = 0; i < 8; i++) {
digitalWrite(rows[i], LOW); //Sets all the rows to low
digitalWrite(cols[i], HIGH); //Sets all the columns to high
}
}