Why isn't my circuit working?!

Hey, arduino community. I am having a problem with one of my circuits. What it is supposed to do is read the binary output from a "solon 1576", interpret it, and display the result on the serial monitor.
Here is the code:

/* binary reader
9/29/12
Racerdude24

you need a binary switch encoder-thing. I have one that looks something like
              | [-] |
              | [5] |
              | [+] |
               \\\\\
wiring:
*common pin to 5v
*binary pin 1 to 9
*binary pin 2 to 8
*binary pin 3 to 7
*binary pin 4 to 6
*binary pins 1, 2, 3, &4 to ground via pull down resistor
*/
int prevNum; //integer for the previus number
int total;


void setup(){
  Serial.begin(4800);
  pinMode(9, INPUT);   //binary inputs number 1
  pinMode(8, INPUT);   //2
  pinMode(7, INPUT);   //3
  pinMode(6, INPUT);   //&4
}

void loop(){
 total = 0; 
  if(digitalRead(9)==HIGH){
    total++;
  }
  if(digitalRead(8)==HIGH){
    total = (total + 2);
  }
  if(digitalRead(7)==HIGH){
    total= (total + 4);
  }
  if (digitalRead(6)==HIGH){
    total=(total+8);
  }
  
    Serial.println(total);
  
  
  total = 0;
  delay(100);
}

the first schematic is the first attachment (circuit binary). My problem with this project is that when the counter is set to 0, the serial monitor reads "0".
But on anything else, the serial monitor reads "15". So I decided, "oh, some of the other output wires must be getting feedback" or something along those lines. So I changed to a different circuit (the second attachment), and the same thing STILL happened! So now i am stumped. There is probably some blatantly obvious problem, but I don't see it.
:0 :0 :0
Thanks
-R

Try a separate pull-down resistor on each pin instead of that shared one.

thanks, not sure why i didn't try that!
:slight_smile: