Common latchpins with 74HC595 Shift Register

Either way, you change a bit or a byte in dataArray[] when you decide to, and then update the shift register outputs - either periodically, or whenever you receive some new input.