byte digits[] = {0x7e, 0x30, 0x6d, 0x79, 0x33, 0x5b, 0x5f, 0x70, 0x7f, 0x7b,0x77, 0x1f, 0x4e, 0x3d, 0x4f, 0x47};
int inputPin[] = {2,3,4,5,6,7,8,9};

int dataPin = 10;
int clockPin = 11;
int latchPin = 12;
int switchPin1 = A0;
int switchPin2 = 13;

int sum1 = 0;
int sum2 = 0;
int sum3 = 0;
int sum4 = 0;



void setup() {
  // put your setup code here, to run once:
  for(int x = 0; x < 8; x++){
    pinMode(inputPin[x], INPUT);
  }
  pinMode(switchPin1, INPUT);
  pinMode(switchPin2, INPUT);
  pinMode(dataPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(latchPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
   if(digitalRead(switchPin1) == LOW && digitalRead(switchPin2) == LOW){
    
      int bit0 = digitalRead(inputPin[0]) * 1;
      int bit1 = digitalRead(inputPin[1]) * 2;
      int bit2 = digitalRead(inputPin[2]) * 4;
      int bit3 = digitalRead(inputPin[3]) * 8;
      int bit4 = digitalRead(inputPin[4]) * 16;
      int bit5 = digitalRead(inputPin[5]) * 32;
      int bit6 = digitalRead(inputPin[6]) * 64;
      int bit7 = digitalRead(inputPin[7]) * 128;
      
        sum1 = bit0 + bit1 + bit2 + bit3 + bit4 + bit5 + bit6 + bit7;
      
      digitalWrite(latchPin, LOW);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[sum1 % 10]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(sum1/10) % 10]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(sum1/100) % 10]);
      shiftOut(dataPin, clockPin, MSBFIRST, 0x00);
      digitalWrite(latchPin, HIGH);
      delay(100);

   }
   else if(digitalRead(switchPin1) == HIGH && digitalRead(switchPin2) == LOW){
      
      int bit0 = digitalRead(inputPin[0]) * 1;
      int bit1 = digitalRead(inputPin[1]) * 2;
      int bit2 = digitalRead(inputPin[2]) * 4;
      int bit3 = digitalRead(inputPin[3]) * 8;
      int bit4 = digitalRead(inputPin[4]) * 16;
      int bit5 = digitalRead(inputPin[5]) * 32;
      int bit6 = digitalRead(inputPin[6]) * 64;
      int bit7 = digitalRead(inputPin[7]) * 128;

       sum2 = bit0 + bit1 + bit2 + bit3 + bit4 + bit5 + bit6 + bit7;

      digitalWrite(latchPin, LOW);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[sum2 % 16]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(sum2/16) % 16]);
      shiftOut(dataPin, clockPin, MSBFIRST, 0x00);
      shiftOut(dataPin, clockPin, MSBFIRST, 0x00);
      digitalWrite(latchPin, HIGH);
      delay(100);
   }
   else if(digitalRead(switchPin1) == LOW && digitalRead(switchPin2) == HIGH){
    
      int bit0 = digitalRead(inputPin[0]) * 1;
      int bit1 = digitalRead(inputPin[1]) * 2;
      int bit2 = digitalRead(inputPin[2]) * 4;
      int bit3 = digitalRead(inputPin[3]) * 8;
      int bit4 = digitalRead(inputPin[4]) * 16;
      int bit5 = digitalRead(inputPin[5]) * 32;
      int bit6 = digitalRead(inputPin[6]) * 64;
      int bit7 = digitalRead(inputPin[7]) * 128;

       sum3 = bit0 + bit1 + bit2 + bit3 + bit4 + bit5 + bit6 + bit7;

      digitalWrite(latchPin, LOW);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[sum3 % 8]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(sum3/8) % 8]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(sum3/64) % 8]);
      shiftOut(dataPin, clockPin, MSBFIRST, 0x00);
      digitalWrite(latchPin, HIGH);
      delay(100);
   }
  else if(digitalRead(switchPin1) == HIGH && digitalRead(switchPin2) == HIGH){
      
      int bit0 = digitalRead(inputPin[0]) * 1;
      int bit1 = digitalRead(inputPin[1]) * 2;
      int bit2 = digitalRead(inputPin[2]) * 4;
      int bit3 = digitalRead(inputPin[3]) * 8;
      int bit4 = digitalRead(inputPin[4]) * 16;
      int bit5 = digitalRead(inputPin[5]) * 32;
      int bit6 = digitalRead(inputPin[6]) * 64;
      int bit7 = digitalRead(inputPin[7]) * -128;

       sum4 = bit0 + bit1 + bit2 + bit3 + bit4 + bit5 + bit6 + bit7;

      digitalWrite(latchPin, LOW);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[abs(sum4) % 10]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(abs(sum4)/10) % 10]);
      shiftOut(dataPin, clockPin, MSBFIRST, digits[(abs(sum4)/100) % 10]);
        
        if(sum4 < 0){
           
           shiftOut(dataPin, clockPin, MSBFIRST, 0x01);
        }
        else{

           shiftOut(dataPin, clockPin, MSBFIRST, 0x00);
        }
      digitalWrite(latchPin, HIGH);
      delay(100);
  }
}
$abcdeabcde151015202530fghijfghij
$abcdeabcde151015202530354045505560fghijfghij
74HC595
74HC595
74HC595
74HC595