Having issues using an Arduino to emulate a shift register. Details inside.

Thanks, that gives me a better idea of what's going on.

Looking at the 4014 data sheet I'm not convinced that code is right, presumably it does work but everything is done on the clock's rising edge not on the load edge.

Anyway I've done a new version.

// S88 pins setup
#define S88DATAIN 5
#define S88DATAOUT 4
#define S88CLOCK 2
#define S88LOAD 3

#define N_REGS	2
#define N_BITS 	(N_REGS * 8)

byte 	S88DataOutShiftRegister[N_BITS];
int 	rd_index = 0;
int 	wr_index = 0;

// S88 test data, when this works completely I want to add the wireless stuff to manipulate this data array.
uint8_t S88data[N_BITS] = { 	
	0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1
	}; 

void setup() {
  attachInterrupt(0, CLOCK, RISING); // Interrupt stuff for the CLOCK
  pinMode(S88DATAOUT, OUTPUT);
}

void loop() { // No loop stuff because it's all interrupt driven.
}

void CLOCK() {

	byte dataInBit 	= (PIND >> S88DATAIN) && 1;
	byte loadBit 	= (PIND >> S88LOAD)  && 1;
	
	if (loadBit) {   	// LOAD (PE pin on 4014) is asserted 
		// put the test data into the FIFO
		for (int i = 0; i < N_BITS; i++) {
			S88DataOutShiftRegister[i] = S88data[i];
		}	
		rd_index = 0;
		wr_index = 0;		
	} else { 			// LOAD is not asserted
		// Get bit from upstream unit and add to FIFO
		S88DataOutShiftRegister[wr_index++] = dataInBit;
		wr_index = wr_index < N_BITS ? wr_index : 0;
	}

	// setup data out so it's at the right level for the downstream unit when the next clock occurs
	if (S88DataOutShiftRegister[rd_index++])
		PORTD |= (1 << S88DATAOUT);
	else 
		PORTD &= ~(1 << S88DATAOUT);
	
	rd_index = rd_index < N_BITS ? rd_index : 0;		

}

As you say I don't have that gear so can't test it, I can't really set up two Arduinos (or indeed any hardware) right now either as I'm in the process of building my workshop and everything is in total disarray.

Anyway you don't have to go this way of course, you may feel more comfortable with the more inline approach used by GuyA's code, but it's worth plugging this in to see what happens.


Rob