short int sPin[] = {9, 8, 7, 6, 5, 4, 3, 2};
int sum = 0;
void setup() {
for(int i = 0; i < 8; i++)
{
pinMode(sPin[i], INPUT_PULLUP);
}
Serial.begin(9600);
}
void loop() {
for(int i = 0; i < 8; i++)
{
sum += digitalRead(sPin[i]);
}
Serial.println(sum);
sum = 0;
}