On it's own both the code and 74hc165 circuit work fine. If I connect my arduino to the 165s data out I receive the correct values for all switches.
However I need to tri-state the chip as the nrf905 module I'm using also uses the SPI bus and without tri-stating the chip I cannot send or receive data which makes the circuit useless because I need to send data. I am attempting to use a 74hc125 chip to tri-state the output.
The connections between the 2 chips are as follows:
74hc165 74hc125
15 (CE) 13 (4C)
9 (Q7) 12 (4A)
74hc125 Arduino
11 (4Y) 12(MISO)
Like I said earlier if I connect arduino pin 12 to the data out (Q7) the values are all correct.
When I connect the the arduino to the buffer out I get the correct data values for switches 1-7 but switch 8 sets the data as 255 it doesn't matter if it's on it's own or not it will always give 255.
I'm sorry if it's horrendously obvious but I have been failing to spot a problem for many hours, any help would be greatly appreciated.
Code: Select all
#include <SPI.h>
const byte SHIFTON = 4; //CE pin for 74hc165
const byte LATCH = 9;
void setup ()
{
SPI.begin ();
Serial.begin (9600);
pinMode (SHIFTON, OUTPUT);
digitalWrite (SHIFTON, LOW); //enable the shift register
pinMode (LATCH, OUTPUT);
digitalWrite (LATCH, HIGH);
byte RXADDRB4;
findRXADDRESS();
byte RXADDRESS[] = {192, 168, 1, RXADDRB4}; //This devices address
//turn shift register off
digitalWrite (SHIFTON, HIGH);
}
void findRXADDRESS()
{
for (int i=8; i < 0; i--) {
digitalWrite (LATCH, LOW);
digitalWrite (LATCH, HIGH);
delay(5);
}
RXADDRB4 = SPI.transfer (0);
}