MC74HC165N + Arduino, Dunno what's the issue

I connected the 74HC165 as per this schematic http://dlnmh9ip6v2uc.cloudfront.net/datasheets/BreakoutBoards/SN74HC165%20Shift-In%20Breakout-v11.pdf and then used this code http://playground.arduino.cc/Code/ShiftRegSN74HC165N with NUMBER_OF_SHIFT_CHIPS set to 1. I get all the weird outputs like:

*Pin value change detected*
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

*Pin value change detected*
Pin States:
  Pin-0: HIGH
  Pin-1: HIGH
  Pin-2: HIGH
  Pin-3: HIGH
  Pin-4: HIGH
  Pin-5: HIGH
  Pin-6: HIGH
  Pin-7: HIGH

*Pin value change detected*
Pin States:
  Pin-0: LOW
  Pin-1: LOW
  Pin-2: HIGH
  Pin-3: LOW
  Pin-4: HIGH
  Pin-5: HIGH
  Pin-6: HIGH
  Pin-7: HIGH

*Pin value change detected*
Pin States:
  Pin-0: HIGH
  Pin-1: HIGH
  Pin-2: HIGH
  Pin-3: HIGH
  Pin-4: HIGH
  Pin-5: HIGH
  Pin-6: HIGH
  Pin-7: HIGH

*Pin value change detected*
Pin States:
  Pin-0: HIGH
  Pin-1: LOW
  Pin-2: LOW
  Pin-3: LOW
  Pin-4: LOW
  Pin-5: LOW
  Pin-6: LOW
  Pin-7: LOW

*Pin value change detected*
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 nothing connected to the input pins of the 165. The worst part is, I get the same output even if nothing is connected to the board... :( however the board seems to be okay with other programs, it's a leonardo compatible board. Also the schematics are for the sparkfun breakout board, I am trying to make that by myself. Also I am not using the capacitor mentioned (it's a decoupling capacitor I guess), is it important? Someone from electronics.stackexchange.com mentioned about pulling down the outputs, can anyone be kind enough to post the entire schematics as expected?

Thanks

Yes a decoupling capacitor between the supply and ground is important, as is actually connecting something to the input pins. Without connecting anything the inputs float and can pick up interference and give you random and changing logic levels. So connect some inputs to ground and others to the supply and try again.

I've just completed a similar problem, however i'm using the CD74HCT165E from Texas Instruments. Sinds i am working with shift registers i lost a lot of hair because it drove me mad.

A better look at the datasheet reveiled that there are a few rules to follow: Quote: For predictable operation the LOW-to-HIGH transition of CE should only take place while CP is HIGH. Also, CP and CE should be LOW before the LOW-to-HIGH transition of PL to prevent shifting the data when PL goes HIGH. Unquote:

I have altered the code witch is found on the playground


BYTES_VAL_T read_shift_regs() { byte bitVal; BYTES_VAL_T bytesVal = 0;

/* Trigger a parallel Load to latch the state of the data lines, */ digitalWrite(clockPin, HIGH); //This rule of code is added to adhere to the digitalWrite(clockEnablePin, HIGH); //This rule of code is added digitalWrite(ploadPin, LOW); delayMicroseconds(PULSE_WIDTH_USEC); digitalWrite(clockPin, LOW); digitalWrite(clockEnablePin, LOW); digitalWrite(ploadPin, HIGH);

/* Loop to read each bit value from the serial out line * of the SN74HC165N. ........................................................... ........................................................................

Ensure that all the wiring is correct.

Good luck with the project..

Here’s a complete example.