I have some older circuit boards that were designed to use a serial stream of data bits in and out for I/O (Originally part of an in-house designed control system). I have the output boards working with the shiftOut() function (allowing me to create 32 output channels with only 2 GPIO pins on the Uno), but I can't seem to get shiftIn() to read from the input cards. The best I can get is a one-time read that apparently inserts an extra bit at the beginning. Then it will not read anything until the Uno is reset.
The boards use a missing pulse detection on the clock pulse to detect a read/write cycle, so there is no enable or latch signal from the Uno necessary (or even a place to connect one).
I couldn't find any sample code for the shiftIn() function, so here is what I wrote:
int dataPin = 9;
int clockPin = 7;
void setup() {
Serial.begin(9600); // start serial
pinMode(clockPin, OUTPUT);
pinMode(dataPin, INPUT);
}
void loop()
{
digitalWrite(clockPin, LOW);
int temp = shiftIn(dataPin, clockPin, MSBFIRST);
Serial.println(temp);
delay(1000);
}
Any ideas if there is something I'm not doing right in the code? I would upload the circuit for the input board, but all I have is a paper copy (it was done with an ancient DOS version of OrCAD 20+ years ago - there isn't even a .pdf of this circuit). I can tell you the the shift register chips are 74HCT165 (chained for 16 inputs - I'm just trying to read the first 8 at this time).