Using Shift Registers

Hey, still new to using the arduino, but that will be apparent if you read this post.

So I’m using the 74HC595 shift register and I’m trying to get several LEDs to light up corresponding with the time, I’m working off of this code

but i’m hung up on how the arduino knows which serial inputs correspond to which register outputs, and also how I might make an array (or what have you) from which I can specify which LEDs I want lit at any given time. From what I can tell the shift register values are represented simply as values in a byte, but how do I know which value is given to each LED and how do I tell the arduino I’m selecting them?

Make a function to turn a led on or off, like in the example.
You could use a byte (8 bits) and set or clear the appropiate bit. After that move the byte to the shift register.
The byte has to keep its value while the Arduino is running. It is a copy of the outputs of the shift register.

The Arduino code has function or macros to set a bit.

The Arduino sets the data for the first output of the shift register, and triggers the clock. The data in the shift register is shifted one position.
This is done 8 times, to get the proper bits into the right position.

That means that if accidently the clock is 7 or 9 times activated, the wrong bits are at the wrong outputs.