Serial not reading Input

So i am trying to read the serial output from a 74HC165N chip. The chip should take 8 binary parallel inputs and convert them to a single serial output.

It does not even seem to read my switches at all. I tried with a different 74HC165N chip and i got the same result, so i don’t think my chips are faulty.

Any idea what’s going on? have i done something incorrectly in my code? This is how i wired up the 74HC165N chip.

1 (Shift/Load) → Arduino #13
2 (Clock) → Arduino #12
3-6, 11-14 (Inputs) → DIP Switches
8 (GND) - Ground
9 (DATA) → Arduino 11
15 (Clock INHB) → Ground
16 (Vcc) → Power +5v

With the switches wired like this

VCC → DIP - > 10k resistor-> 74165 A pin

//The terminology used here (PL, CP, Q7 and so on) are taken DIRECTLY from the 74HC165's datasheet.

#define PIN_PL (13) //pin 13 on arduino goes to pin 1 of 74HC165
#define PIN_CP (12) //pin 12 on arduino goes to pin 2 of 74HC165
#define PIN_Q7 (11) //pin 11 on arduino goes to pin 9 of 74HC165
//Hardwire pin 15 of both 74HC165 chips to ground to enable them all the time.

//For peace of mind I also hardwired pin 10 of the upstream chip to
//GND to force zeroes to be shifted in instead of allowing it to float.
//Given that the arduino is "downstream".

void setup() 
{
  Serial.begin(9600);

  pinMode(PIN_PL, OUTPUT);
  pinMode(PIN_CP, OUTPUT);
  pinMode(PIN_Q7, INPUT);

  digitalWrite(PIN_PL, HIGH);
  digitalWrite(PIN_CP, LOW);

  int i;
  int j;
  int value;
  
  //read the switches 8 times to prove
  //that the system is stable
  for(i = 0 ; i < 7 ; i++)
  {
    //load logic bits from the DIP switches
    digitalWrite(PIN_PL, LOW);  //LOAD BITS
    //reset "load" line, this freezes the internal buffer on both chips
    digitalWrite(PIN_PL, HIGH);
              
    for(j = 0 ; j < 8 ; j++)
    {
      value = digitalRead(PIN_Q7);
  
      digitalWrite(PIN_CP, HIGH);
      digitalWrite(PIN_CP, LOW);
      
      //print switch's value
      Serial.print(value);
      
    }

    Serial.println("");    
    Serial.println("----------------");
    delay(1000);
  }   
}

void loop()
{
}

What does it print?

It simply prints “00000000”, as if all the switches were off even if they are on.

I tried with a different code from the arduino playground as below(changing the pins as required).

http://www.arduino.cc/playground/Code/ShiftRegSN74HC165N

With the only change i made being

#define NUMBER_OF_SHIFT_CHIPS   1
int ploadPin        = 13;  // Connects to Parallel load pin the 165
int clockEnablePin  = 10;  // Connects to Clock Enable pin the 165
int dataPin         = 11; // Connects to the Q7 pin the 165
int clockPin        = 12; // Connects to the Clock pin the 165

And with that it prints as below, regardless the state of my switches.

Pin States:
  Pin-0: LOW
  Pin-1: LOW
  Pin-2: LOW
  Pin-3: LOW
  Pin-4: LOW
  Pin-5: LOW
  Pin-6: LOW
  Pin-7: LOW

I have a feeling its something to do with the way i have the switches wired. This is how i have them now.

VCC → Switch - > 10K Resistor(connected to ground) - > 74165 A pin
VCC → Switch - > 10K Resistor(connected to ground) - > 74165 B pin
etc…

Could you sketch that? The way you describe it, it sounds like the pin is connected to ground.

I’ve attached the schematic of it, I’m essentially trying to do what this guy did, but with one register.

http://wardyprojects.blogspot.com.au/2011/05/74hc165-piso-shift-register-arduino.html

Schematic.png

ThievingSix: I tried with a different code from the arduino playground as below(changing the pins as required).

http://www.arduino.cc/playground/Code/ShiftRegSN74HC165N

With the only change i made being ...

That's not the only change you made. He had:

  /* Trigger a parallel Load to latch the state of the data lines,
    */
    digitalWrite(clockEnablePin, HIGH);
    digitalWrite(ploadPin, LOW);
    delayMicroseconds(PULSE_WIDTH_USEC);
    digitalWrite(ploadPin, HIGH);
    digitalWrite(clockEnablePin, LOW);

You have:

    //load logic bits from the DIP switches
    digitalWrite(PIN_PL, LOW);  //LOAD BITS
    //reset "load" line, this freezes the internal buffer on both chips
    digitalWrite(PIN_PL, HIGH);