// Define pins for rows and columns
const int rows = 8;
const int cols = 8;
int rowPins[rows] = {2, 3, 4, 5, 6, 7, 8, 9};
int colPins[cols] = {10, 11, 12, 13, 14, 15, 16, 17};
void setup() {
// Set up row pins as OUTPUT
for (int i = 0; i < rows; i++) {
pinMode(rowPins[i], OUTPUT);
digitalWrite(rowPins[i], LOW);
}
// Set up col pins as OUTPUT
for (int i = 0; i < cols; i++) {
pinMode(colPins[i], OUTPUT);
digitalWrite(colPins[i], HIGH);
}
}
void loop() {
// Display each row in sequence
for (int row = 0; row < rows; row++) {
// Turn on the current row
digitalWrite(rowPins[row], HIGH);
// Turn on LEDs for the current row
for (int col = 0; col < cols; col++) {
digitalWrite(colPins[col], LOW);
delayMicroseconds(50); // Adjust the delay as needed for brightness
digitalWrite(colPins[col], HIGH);
}
// Turn off the current row for the next iteration
digitalWrite(rowPins[row], LOW);
delay(5); // Adjust the delay between rows
}
}