int inputPin[]={2,3,4,5};
int sum = 0;
void setup() {
// put your setup code here, to run once:
for(int i = 0; i < 4; i++){
pinMode(inputPin[i], INPUT);
}
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
int bit1 = digitalRead(inputPin[0]) * 1;
int bit2 = digitalRead(inputPin[1]) * 2;
int bit3 = digitalRead(inputPin[2]) * 4;
int bit4 = digitalRead(inputPin[3]) * 8;
sum = bit1 + bit2 + bit3 + bit4;
Serial.print("digit:");
Serial.println(sum);
}