byte digits[] = {0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b, 0x77, 0x1f, 0x4e, 0x3d, 0x4f, 0x47};
int inputPin[] = {2, 3, 4, 5};
int dataPin = 6;
int clockPin = 7;
int latchPin = 8;
int sum = 0;
void setup() {
//Put your setup code here, to run once:
for(int i = 0; i < 4; i++){
pinMode(inputPin[i], INPUT);
}
pinMode(dataPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(latchPin, OUTPUT);
}
void loop() {
//Put your main code here, to run repeatedly:
int bit0 = digitalRead(inputPin[0]) * 1;
int bit1 = digitalRead(inputPin[1]) * 2;
int bit2 = digitalRead(inputPin[2]) * 4;
int bit3 = digitalRead(inputPin[3]) * 8;
sum = bit0 + bit1 + bit2 + bit3;
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digits[sum]);
digitalWrite(latchPin, HIGH);
delay(10);
}