All pins are first set to INPUT_PULLUP in setup then in loop() I check wether they touch with the first for loop, second loop is to reset the data sent to processing.
for (int i = 0; i < 12; i++) {
pinMode(i, OUTPUT);
digitalWrite(i, LOW);
for (int x = 0; x < 12; x++) {
if (i != x) {
if (digitalRead(x) == LOW) {
partsConnected[x] = 1;
}
}
}
pinMode(i, INPUT_PULLUP);
}
sendArrayData();
for (int i = 0; i < 12; i++) {
partsConnected[i] = 0;
}