Input problems with 74HC595

ShiftIn Tutorial : http://www.arduino.cc/en/Tutorial/ShiftIn

And here the datasheet links - take your pick : CD4021 Datasheet pdf - 8-Stage Static Shift Register - Fairchild Semiconductor

Check it out. download the datasheet and try to understand it.

And I did use the chip 4021 and do a test code. I was using a telephone keypad.

Here the test code.

//**************************************************************//
//  Name    : shiftIn Example 1.1                              //
//  Author  : Carlyn Maw                                        //
//  Date    : 25 Jan, 2007                                      //
//  Version : 1.0                                               //
//  Notes   : Code for using a CD4021B Shift Register    	//
//          :                                                   //
//****************************************************************
// Modify code from the original
// Use only shiftIn () function
/* 
    --------------
     1    2      3  <-- Col 1  
     4    5      6  <-- Col 2
     7    8      9  <-- Col 3
     *    0      #  <-- Col 4
     -------------
    /\   /\      /\
     |    |       |
    Row 1 Row 2  Row 3 
    
   Telephone keypad pinouts
   
   col 1, col 2, col 3, col 4, row 1, row 2, row3, GND
   4021 connection :
   col 1 : pin 7
   col 2 : pin 6
   col 3 : pin 5
   col 4 : pin 4
   row 1 : pin 13
   row 2 : pin 14
   row 3 : pin 15

   pin 1 of the 4021 - PI-8 held HIGH with a 1 k pull-out resistor.
   
   All keypad pins are with a 1 K pull-up resistor.
   
   Also Serial In - pin 11 of the 4021 held HIGH with a 1 k pull-up resistor
   
   Therefore : 1CCCCRRR
   
   Button = 1 = 0b10111011 = 0xBB = 187
   Button = 2 = 0b10111101 = 0xBD = 189
   Button = 3 = 0b10111110 = 0xBE = 190
   Button = 4 = 0b11011011 = 0xDB = 219
   Button = 5 = 0b11011101 = 0xDD = 221
   Button = 6 = 0b11011110 = 0xDE = 222
   Button = 7 = 0b11101011 = 0xEB = 235
   Button = 8 = 0b11101101 = 0xED = 237
   Button = 9 = 0b11101110 = 0xEE = 238
   Button = * = 0b11110011 = 0xF3 = 243
   Button = 0 = 0b11110101 = 0xF5 = 245
   Button = # = 0b11110110 = 0xF6 = 246
   Button = None press = 0b11111111 = 0xFF = 255 
*/

//define where your pins are
int latchPin = 10;
int dataPin = 12;
int clockPin = 11;

//Define variables to hold the data 
//for shift register.
//starting with a non-zero numbers can help
//troubleshoot
byte switchVar;

void setup() {
  //start serial
  Serial.begin(9600);

  //define pin modes
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT); 
  pinMode(dataPin, INPUT);
  switchVar = 0b11111111;

}

void loop() {

  //Pulse the latch pin:
  //set it to 1 to collect parallel data
  digitalWrite(latchPin,HIGH);
  //set it to 1 to collect parallel data, wait
  delayMicroseconds(20);
  //set it to 0 to transmit data serially  
  digitalWrite(latchPin,LOW);

  //while the shift register is in serial mode
  //collect each shift register into a byte
  //the register attached to the chip comes in first 
  switchVar = shiftIn(dataPin, clockPin,LSBFIRST);

  //Print out the results.
  //leading 0's at the top of the byte 
  //(7, 6, 5, etc) will be dropped before 
  //the first pin that has a high input
  //reading  
  Serial.println(switchVar, BIN);
  // or
  Serial.println(switchVar, DEC);
  
//white space
Serial.println("-------------------");
//delay so all these print satements can keep up. 
delay(1000);

}