Shift registers are used to convert a serial string of bits into parallel data, or vice-versa.

Output shift register

An output shift register such as the 74HC595 lets you stream data from an Arduino data pin, where it is "latched" by the shift register into (typically 8) ports simultaneously. Normally you communicate with a shift register using three control signals, in addition to power and ground:

  • MOSI (Master Out, Slave In) - that is, the data
  • SCK (Serial clock) - this tells the register when a new data bit arrives
  • LATCH - tells the register to transfer the current bit pattern from a holding register to the output pins.

Shift registers can be daisy-chained, they typically have an "overflow" pin which is used to transfer the oldest incoming bit from one register to the next.

So, for example, to send 16 bits you would bring the LATCH pin low, transfer 16 bits (the first 8 would be pushed out of the first shift register into the second one) and then when the LATCH pin goes high, both registers now have the appropriate parts of the 16 bits on their output pins.

Typical applications of the 74HC595 are to control banks of LEDs, or other similar devices.


Input shift register

An input shift register such as the 74HC165 lets you stream data from the register to an Arduino input pin. Normally you communicate with an input shift register using three control signals, in addition to power and ground:

  • MISO (Master In, Slave Out) - that is, the data
  • SCK (Serial clock) - this tells the register when to send a new bit
  • LOAD - tells the register to transfer the current bit pattern from the input pins to its holding register.

Shift registers can be daisy-chained, they typically have an "overflow" pin which is used to transfer the oldest incoming bit from one register to the next.


SPI

Shift registers are easily coded for by using SPI (Serial Peripheral Interface) because that supports the clocking of bits in or out in hardware.


Shiftin / ShiftOut

An alternative to SPI is using software bit-banged bit transfer such as shiftIn and shiftOut


See also: