Get the state of a pin?

I’m using a 74hc595 shift register and need a way to get the state of the Q0-Q7 pins back. Does anyone know how to do that? Thanks!

bob5390: I'm using a 74hc595 shift register and need a way to get the state of the Q0-Q7 pins back. Does anyone know how to do that? Thanks!

Call the digitalRead() function?

Power_Broker: Call the digitalRead() function?

I've attempted that to not much avail. I need the state of the Q0-Q7 pins which I can easily write to but not as easily read from. I'm trying to save pins on the arduino which is why I used the 74hc595 in the first place. This contains information on the register but only to write to it: https://www.arduino.cc/en/Tutorial/ShiftOut

You can't really read back from the shift register pins. You could connect the q' pin that would go to the next shift register to an input pin and shift in new values through it and read them off one at a time.

Do you think the shift register isn't putting out what you told it to?

Delta_G: Do you think the shift register isn't putting out what you told it to?

I was just trying to get back what it had done and change it.

Delta_G: You can't really read back from the shift register pins. You could connect the q' pin that would go to the next shift register to an input pin and shift in new values through it and read them off one at a time.

Thanks for the clarification!

Do you not remember what you told it to do? That comes from your code so you shouldn't need to read it. You should know what you wrote to it.

A shift register might not be outputting the programmed value is if the output is damaged, overloaded (e.g. grounded) or forced high by an external signal.

If that is even possible and something to worry about, you need to connect an input pin to that output and read its state directly.

Connect the inputs of a 74HC165 to the outputs of the 74HC595, sample them, and then shift in the data to confirm what you sent out is actually appearing.

That is the basis for cable testers as well, altho with an open drain '595 part so shorted outputs aren't a problem.

bob5390: I was just trying to get back what it had done and change it.

If it's driven by output pins, your program should be able to know what's in it since it put the data there in the first place.

bob5390: I'm using a 74hc595 shift register and need a way to get the state of the Q0-Q7 pins back. Does anyone know how to do that? Thanks!

These devices are serial-in, parallel out.

1 - attach arduino input pins to Q0-Q7

2 - attach an ardiuino input pin to Q7, and shift bits into the register to read the bits off as the drop off the end. Shift in the bits that yo read as you read them to restore the state of the register

3 - normally, your program would be putting data into the register. Why not write down somewhere what you last loaded into it and refer to that?