It looks like your counter array also depends on sizeTest == 4 since it does this comparison at the end of the scan
else if (counter[i] == 3) {
Serial.println(" O");
s[i] = '0';
fail = true;
}
but since you are looping 12 times, counter will be 11 if the pin is open, not 3