# Shift register parallel in serial out

I'm doing a project in which I will need these and I bought two to learn how to use them and daisy chain them. I'm using the 74HC166, and I'm having some problems. I'm using them according to the table function of the datasheet, which I attach:

So, it is a 8 bit PISO shift register. This is how I'm interpreting the table. I don't know how to read it so I had to guess and I obviously made mistakes.

If I want to load the states into the register, the PE and CE have to be LOW before I trigger the CP from LOW to HIGH. After that I can just start reading values from Q7, and to shift the value I will read from Q7 I have to trigger again the CP with PE being HIGH and CE being LOW. I don't know how to use, or when I should use the "hold 'do nothing'" row. and this doesn't work because I'm not reading the correct states. Right now I have just plugged the Dn pins to HIGH or LOW directly to try it.

This is the code I'm using:

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

/* Loop to read each bit value from the serial out line
* of the SN74HC166.
*/
digitalWrite(clockPin,LOW);
bytesVal |= (bitVal << ((DATA_WIDTH-1) - 0));
delayMicroseconds(PULSE_WIDTH_USEC);
digitalWrite(clockPin,HIGH);

digitalWrite(clockPin,LOW);
bytesVal |= (bitVal << ((DATA_WIDTH-1) - 1));
delayMicroseconds(PULSE_WIDTH_USEC);
digitalWrite(clockPin,HIGH);


This should read the first two states. and I would loop over the "reading" parragraph to read them all. PULSE_WIDTH_USEC is 5. (5 microseconds).

So, how do I use these registers.

EDIT: Ok, I just rewrote the code from scratch and it worked... It was probably something silly.

• So what are you getting then? – Ignacio Vazquez-Abrams Sep 27 '13 at 10:34
• @IgnacioVazquez-Abrams Just incorrect values. Some of them HIGH, some of them LOW, but they do not correspond to the real values. Is what I'm doing supposed to work? – MyUserIsThis Sep 27 '13 at 10:35
• Do they have the correct number of bits set, or are they completely off? – Ignacio Vazquez-Abrams Sep 27 '13 at 10:38
• @IgnacioVazquez-Abrams I don't understand your question. wHAt do you mean by being off? – MyUserIsThis Sep 27 '13 at 10:47
• By not having the correct number of bits set. – Ignacio Vazquez-Abrams Sep 27 '13 at 10:48