int colAnodes[] = {23, 25, 27};
int rowCathodes[] = {29, 39, 51};
unsigned long showTimeL = millis() + 1000;
unsigned long showTimeD = millis() + 2000;
unsigned long showTimeW = millis() + 3000;
boolean letters[3][3][3] = {
{
{1, 1, 1},
{0, 0, 1},
{0, 0, 1}
},
{
{1, 1, 1},
{1, 0, 1},
{0, 1, 0}
},
{
{1, 1, 1},
{0, 1, 1},
{1, 1, 1}
}
};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
//Serial.println(sizeof(colAnodes) / sizeof(colAnodes[0]));
for (int pointer = 0; pointer <= 2; pointer ++) {
pinMode(colAnodes[pointer], OUTPUT);
digitalWrite(colAnodes[pointer], LOW);
}
//Serial.println (sizeof(rowCathodes) / sizeof(rowCathodes[0]));
for (int pointer = 0; pointer <= 2; pointer ++) {
pinMode(rowCathodes[pointer], OUTPUT);
digitalWrite(rowCathodes[pointer], HIGH);
}
for(int letterPointer = 0; letterPointer<=2; letterPointer ++){
Serial.print(letters[letterPointer][0][0]); Serial.print(letters[letterPointer][1][0]); Serial.println(letters[letterPointer][2][0]);
Serial.print(letters[letterPointer][0][1]); Serial.print(letters[letterPointer][1][1]); Serial.println(letters[letterPointer][2][1]);
Serial.print(letters[letterPointer][0][2]); Serial.print(letters[letterPointer][1][2]); Serial.println(letters[letterPointer][2][2]);
Serial.println("\n");
}
}
void loop() {
// put your main code here, to run repeatedly:
if (millis() < showTimeL) {
lightLED(0, 0);
lightLED(0, 1);
lightLED(0, 2);
lightLED(1, 2);
lightLED(2, 2);
}
if ((millis() > showTimeL) && (millis() < showTimeD)) {
lightLED(0, 0);
lightLED(0, 1);
lightLED(0, 2);
lightLED(1, 0);
lightLED(1, 2);
lightLED(2, 1);
}
if ((millis() > showTimeD) && (millis() < showTimeW)) {
lightLED (0, 0);
lightLED (0, 1);
lightLED (0, 2);
lightLED (1, 1);
lightLED (1, 2);
lightLED (2, 0);
lightLED (2, 1);
lightLED (2, 2);
}
if (millis() > showTimeW) {
showTimeL = millis() + 1000;
showTimeD = millis() + 2000;
showTimeW = millis() + 3000;
}
}
void lightLED(int col, int row) {
for (int pointer = 0; pointer <= (sizeof(colAnodes) / sizeof(colAnodes[0])) - 1; pointer ++) {
pinMode(rowCathodes[pointer], OUTPUT);
digitalWrite(rowCathodes[pointer], HIGH);
}
for (int pointer = 0; pointer <= (sizeof(colAnodes) / sizeof(colAnodes[0])) - 1; pointer ++) {
pinMode(colAnodes[pointer], OUTPUT);
digitalWrite(colAnodes[pointer], LOW);
}
digitalWrite(colAnodes[col], HIGH);
digitalWrite(rowCathodes[row], LOW);
}