Shift Register

A Shift Register is a serial device which is a useful way of multiplying your outputs on an Arduino. For example, the 74HC595 8-bit Shift Register can take 3 digital pins from the arduino, and use them to individually control 8 LEDs. It does this by accepting a time-encoded 8-bit serial input from the Arduino, instead of requiring a direct data connection between each LED and an arduino outlet.

How it Works
During a message to the Shift Register, one arduino pin (the dataPin) sends a stream of on/off voltage bits (understood by the arduino programming as 0's and 1's, HIGH's and LOW's), and a second pin (the clock pin) tells the Shift Register where each individual bit begins and ends. The Third pin (a latch pin) is set low to tell the shift register to listen to the commands at this time (which enables a sketch to do other things without constantly sending information to the shift register). The latch pin goes high after the data has been sent, telling the shift register to stop listening. When using the 74HC595 8-bit Shift Register connected to 8 LED's (and resistors), if we wanted to only light up the eighth LED: Step 1- The Latch pin would have to be set LOW, to tell the SR to save the information in a latch register. Step 2- The data pin would start sending the 8-bit message "00000001" in a constant stream. (remember, this is actually "voltage off, voltage off," etc,) Step 3- The clock pin would tell the Shift Register how to break-up that data stream into the correct 8-bit message, so that it becomes "0 0 0 0 0 0 0 1". Step 4- The Latch pin would be set back to HIGH, to close the latch register. Step 5- The Shift Register reads the message stored in the latch register, and then uses it as a map to set it's own outputs to LOW or HIGH. There are eight bits in that message, because it's an 8-bit shift register. It's outputs start at zero, so the Shift Register reads it as output #0 is LOW, output #1 is LOW, Output #2 is LOW...etc, until it reaches the eighth digit, which, in this case is a 1, and so it set's output #7 to HIGH.

How the arduino programming handles it
The arduino's programming has a few commands for using things like Shift Registers, which require a "timed data stream" (Serial) input. The command which involves sending data this way is the shiftOut command. It's usage looks like this:  Syntax  shiftOut( dataPin, clockPin, bitOrder, value  )  Parameters  dataPin: the arduino pin on which to output each bit (integer) clockPin: the arduino pin to toggle once the dataPin has been set to the correct value (integer) bitOrder: which order to shift out the bits; either MSBFIRST or LSBFIRST (Most Significant Bit First, or, Least Significant Bit First) value: the data to shift out. (8-byte pattern)  Note:  The bit order is used to indicate whether the bit pattern being sent to the outputs of the shift register will start at the first output (output #0) LSBFIRST, or the opposite, starting with the last output (output #7) MSBFIRST.

Since the 74HC595 8-bit Shift Register is a SIPO (Serial-in,Parallel-out) latched device, it requires a latch pin, which is used before and after the shiftOut command. It is set LOW to open the latch register to begin storing the data into a position for the Shift Register to use, and then HIGH, to close off input access to the latch register.

Example Arduino Sketch
Note, all of the // commands in this sketch may be omitted because they are ignored by the arduino IDE compiler and aren't sent to the arduino itself, they are programmer comments intended to explain what each line does. Normally, comments aren't used on every line, but this allows a breakdown instruction of the code itself for anyone not familiar with programming and just getting started.