// code to designate the pins for both the coloums and rows which will later be declared
int colAnodes[] {25, 35, 45};
int rowCathodes[] {29, 39, 49};
// when timer hits designated milisecond time, 1000 2000 or 3000, the grid displays the L W or S time dependent on the count
unsigned long showLTime = millis() + 1000;
unsigned long showWTime = millis() + 2000;
unsigned long showSTime = millis() + 3000;
void setup() {
//turns the coloum pins low, declares the colum pins as output.
for (int pointer = 0; pointer <= sizeof(colAnodes) / sizeof(colAnodes[0]); pointer ++) {
pinMode(colAnodes[pointer], OUTPUT);
digitalWrite(colAnodes[pointer], LOW);
}
// turns the row pins high, and declares them as output.
for (int pointer = 0; pointer <= sizeof(rowCathodes) / sizeof(rowCathodes[0]); pointer ++) {
pinMode(rowCathodes[pointer], OUTPUT);
digitalWrite(rowCathodes[pointer], HIGH);
}
}
void loop() {
// turns on certain LEDs on the grid.
if(millis() < showLTime){
//used to display L.
lightLED(0, 0);
lightLED(1, 0);
lightLED(2, 0);
//lightLED(0, 1);
lightLED(2, 1);
//lightLED(2, 2);
//lightLED(0, 2);
//lightLED(1, 2);
lightLED(2, 2);
}
if ((millis()> showLTime) && (millis()<showWTime)){
// displays W
lightLED(0, 0);
lightLED(1, 0);
lightLED(2, 0);
//lightLED(0, 1);
lightLED(2, 1);
lightLED(2, 2);
lightLED(0, 2);
lightLED(1, 2);
lightLED(2, 2);
lightLED (1,1);
}
if ((millis()> showWTime) && (millis()<showSTime)){
//displays S
lightLED(0, 0);
lightLED(1, 0);
lightLED(2, 0);
lightLED(0, 1);
lightLED(2, 1);
lightLED(2, 2);
lightLED(0, 2);
lightLED(1, 2);
lightLED(2, 2);
lightLED(1, 1);
}
//restarts the timer so that the letters restart the printing process.
if(millis() > showSTime){
showLTime = millis() +1000;
showWTime = millis() +2000;
showSTime = millis() +3000;
}
}
void lightLED(int row, int col) {
//lightLED is set to void, and is used to turn on and off the power of the coloums and rows.
for (int pointer = 0; pointer <= sizeof(colAnodes) / sizeof(colAnodes[0]); pointer ++) {
digitalWrite(colAnodes[pointer], LOW);
}
for (int pointer = 0; pointer <= sizeof(rowCathodes) / sizeof(rowCathodes[0]); pointer ++) {
digitalWrite(rowCathodes[pointer], HIGH);
}
digitalWrite(rowCathodes[row], LOW);
digitalWrite(colAnodes[col], HIGH);
}