const uint8_t n = 11; // row size
// rows are analog inputs with 10k resistor to GND.
uint8_t rowPins[n] = { 1, 2, 3, 4, 11, 12, 13, 14 }; // row pins.
// columns are digital pins connected to the sensor inputs.
uint8_t colPins[n] = { 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, 5 }; // col pins.
int ldr[n][n];
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void setup() {
analogReadResolution(14);
Serial.begin(115200);
for (uint8_t i = 0; i < n; i++) {
for (uint8_t j = 0; j < n; j++) {
pinMode(rowPins[i], OUTPUT);
pinMode(colPins[j], INPUT);
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
void loop() {
for (uint8_t i = 0; i < 8; i++) {
for (uint8_t j = 0; j < n; j++) {
pinMode(rowPins[i], INPUT_PULLDOWN); // enable rows...
ldr[i][j] = analogRead(rowPins[i]);
int sensorValue = ldr[j][i];
Serial.print(sensorValue);
Serial.print(" ");
pinMode(rowPins[i], OUTPUT); // disable rows..
delay(100);
}
Serial.println();
}
Serial.println();
}