Not quite correct.
One thing to keep in mind is that numbering and indexing starts at zero
so bit numbering starts at zero not one.
In this statement, the bits are off by one.
If I have my execute tray as this: 00000100. Now I want to turn on bit 2 and leave 3 on, I should send this byte: 00000110. Latch. Now 2 and 3 are on.
example: 00000100 has bit 2 set.
Also, a 595 shift register is not capable of GPIO since the 8 data pins are output only.
You can shift in bits to be stored on the output pins, but you can not use the data pins as inputs .
But in the bigger picture, there some important things to keep in mind.
There are actually two types of shift registers.
- latching outputs with an internal storage register (example: 74hc595, 74hc4094)
- non latching outputs. (example: 74ls164)
The difference is that one has an extra temporary 8 bit register that can be loaded by shifting in bits which can be moved to the output pins using a latch signal.
The other type shifts in bits and the output pins are immediately affected as each bit is clocked in.
There are actually 3 function signals typically called.
(different chips use different names for them but the function is the same)
- data
- clock
- latch (only used on the latching shift registers like the 74hc595
Each time the clock signal is triggered, the signal level (bit) on the data signal pin is clocked in as all the other bits are shifted over to make room.
On a non latching shift register the output pins are altered immediately.
On a latching shift register an internal register is updated and then at some point in the future (usually after all 8 bits have been shifted in) the internal register can be transferred to the output pins by triggering the latch signal.
--- bill