No pin 13 is an output not an input.
It should be connected to the input pin of the arduino or the serial input of a cascading chip.
What else in the data sheet are you having trouble with?
I have found that TI data sheets are always very thorougher but steeped in their own convention. Phillips ( or NXP as they are now) can be a bit wordy but are easier to follow.
...and so it came to pass, that the project was brought back online and LO! it didn't work! Grr.
I did have all this working nicely with a 165 chip: Marcel Lenormand: All together now...
but as I resurrected the project I found the 165 setup wasn't working but decided to move to the 74HC166 chip so I'm on the same page as my chum whom I'm developing this for.
I've stripped back my code to troubleshoot it. (no shiftOUT or vUSB)
All I'm getting back is zeros - even when I bring one of the input pins high with a flying lead from +5V
I'm missing something. Does anyone have a keener eye than me?
int latchIN = 8; // PE pin 15 74HC166
int clockIN = 9; // CP 7
int dataIN = 10; // DS 13
int LED = 13;
void setup() {
pinMode(latchIN, OUTPUT);
pinMode(clockIN, OUTPUT);
pinMode(dataIN, INPUT);
digitalWrite(latchIN, HIGH);
Serial.begin(57600);
}
void loop(){
read();
delay(111);
}
//////////////////////////////////////
void read(){
digitalWrite(LED, HIGH);
digitalWrite(clockIN, HIGH);
digitalWrite(latchIN, LOW); // loads her up to be read
delay(11);
digitalWrite(latchIN, HIGH); // (on a rising signal)
for (int i=0; i <= 7; i++){ // count through the items (bits) in the array
shiftIN(i); // call the function to set the bit in the array
delay(11);
}
Serial.println(); ///////// ==========
digitalWrite(LED, LOW);
digitalWrite(latchIN, HIGH); // close her down and switch to display mode
}
//////////////////////////////////////
void shiftIN(int i){
digitalWrite(clockIN, LOW);
int TEMP = digitalRead(dataIN);
digitalWrite(clockIN, HIGH);
Serial.print(TEMP); ///////// ==========
}
//////////////////////////////////////
I've added a couple of delays along the way to slow things down in case it was all moving too fast. It made no difference. Serial monitor outputs lines of 8 ZEROS. (exception - jiggling the breadboard wiring sometimes outputs a line of ONES.
My friend and I had both ordered some 166s but during the shipping wait I happily found a 165 in my stash of bits. Don't know where it came from. Hence, I ran it all up with the 165 and got on quite well with it.
I started this thread whilst trying to get my head around the different pin labeling on the 166. We didn't get time to make the swap back then but the project is back on the table now and we're both stumped as to why it's not working.
The most misleading part of this image however is that the blue lead from Arduino GND looks like it goes to PIN 15 on the 166 - it actually goes to the ground rail and PIN 15 is connected to Ard 8, but is hidden.
You will probably find a line over the words Master Reset. This indicates that the pin should have a zero to activate the name of the function. That is to reset it you need to put it low. Therefore to take it out of reset you place it high. This is the way most chips work.
Yes sorry they are both the same type but if you look at the pin out they have different functions of different pins. So you can't just swap them out you have to wire them up differently.
74LS165 - serial output shift register
74LS166 - serial output shift register shift register
For example pin 9 on the 165 is the serial output, where as pin 9 on the 166 is the ~Clear (note a ~ in front of a line indicates it is active when low, just like a bar over the top).
Note you will also need a decoupling capacitor across the power lines.