const int VCC[] = {2, 3, 4, 5, 6, 7, 8, 9};
const int GND[] = {10, 11, 12, A4, A3, A2, A1, A0};
void setup() {
Serial.begin(9600);
for(int i = 0 ; i < 8 ; i++){
pinMode(VCC[i], OUTPUT);
}
for(int i = 0 ; i < 8 ; i++){
pinMode(GND[i], INPUT);
}
}
void loop() {
long pulsante = 0;
bool controlloVCC=0;
bool controlloGND=0;
for(int i = 0 ; i < 8 ; i++){
digitalWrite(VCC[i], HIGH );
for(int j = 0 ; j < 8 ; j++){
controlloGND = digitalRead(GND[j]);
pulsante++;
/*Serial.print(pulsante);
Serial.print("\t");
Serial.println(controlloGND);*/
delay(100);
if(controlloGND) Serial.println(pulsante);
}
digitalWrite(VCC[i], LOW );
}
/*for(int i = 0 ; i < 8 ; i++){
digitalWrite(VCC[i], HIGH);
for(int j = 0 ; j < 8 ; j++){
controlloGND = digitalRead(GND[j]);
pulsante++;
if(controlloGND) j=8;
}
delay(1);
if(controlloGND) i=8;
}
Serial.println(pulsante);
Serial.println("ciao");
pulsante = 0;
controlloVCC=0;
controlloGND=0;*/
}