// 2-dimensional array of row pin numbers:
const int rows[10] = {
16, 17, 18, 19, 21, 22, 4, 5, 13, 14
};
// 2-dimensional array of column pin numbers:
const int cols[6] = {
23, 25, 26, 27, 32, 33
};
void setup() {
Serial.begin(115200);
// initialize the I/O Rows pins as outputs iterate over the pins:
for (int thisPin = 0; thisPin < 10; thisPin++) {
// initialize the output pins:
pinMode(rows[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that the LEDS are off:
digitalWrite(rows[thisPin], HIGH);
//Serial.print("row: ");Serial.println(rows[thisPin]);
}
// initialize the I/O Cols pins as outputs iterate over the pins:
for (int thisPin = 0; thisPin < 6; thisPin++) {
// initialize the output pins:
pinMode(cols[thisPin], OUTPUT);
// take the col pins (i.e. the cathodes) high to ensure that the LEDS are off:
digitalWrite(cols[thisPin], LOW);
//Serial.print(" col: ");Serial.println(cols[thisPin]);
}
// End setup
}
void loop() {
digitalWrite(cols[0], HIGH);
digitalWrite(rows[0], LOW);//digitalWrite(rows[1], HIGH);
digitalWrite(cols[2], HIGH);
digitalWrite(rows[0], LOW);//digitalWrite(rows[1], LOW);
digitalWrite(cols[1], HIGH);
digitalWrite(rows[2], LOW);//digitalWrite(rows[1], HIGH);
// End loop
}
void red(int row, int col){
digitalWrite(cols[col], HIGH);
digitalWrite(rows[row], LOW);digitalWrite(rows[row+1], HIGH);
}
void yellow(int row, int col){
digitalWrite(cols[col], HIGH);
digitalWrite(rows[row], LOW);digitalWrite(rows[row+1], LOW);
}
void dark(int row, int col){
digitalWrite(cols[col], LOW);
digitalWrite(rows[row], HIGH);digitalWrite(rows[row+1], HIGH);
}
void test(){
red(0,0); //rows, cols
delay(1000);
yellow(0,0); //rows, cols
delay(1000);
dark(0,0); //rows, cols
delay(1000);
red(0,1); //rows, cols
delay(1000);
yellow(0,1); //rows, cols
delay(1000);
dark(0,1); //rows, cols
delay(1000);
red(2,0); //rows, cols
delay(1000);
yellow(2,0); //rows, cols
delay(1000);
dark(2,0); //rows, cols
delay(1000);
red(2,1); //rows, cols
delay(1000);
yellow(2,1); //rows, cols
delay(1000);
dark(2,1); //rows, cols
delay(1000);
red(0,0); //rows, cols
red(0,1); //rows, cols
red(2,0); //rows, cols
red(2,1); //rows, cols
delay(1000);
dark(0,0); //rows, cols
dark(0,1); //rows, cols
dark(2,0); //rows, cols
dark(2,1); //rows, cols
delay(1000);
}