Like any other shift register setup, the build can be expanded by connecting the QH’ pin of the first 595 to the SER pin of the second. There are just three wires connecting the microcontroller to the shift register – SER, SRCLK, and RCLK.
Most microprocessors have an Serial Peripheral Interface, and using an SPI bus means a lot less mucking about.Īn ATmega168 was used for this build, although most Atmel chips can be made to work as an SPI master device. In a 595, bits for each position in the register are sent over one at a time. ’s earlier tutorial of the 595 shift register goes through the functions of a shift register pin by pin.
Hack a Day’s very own (and very prolific contributor) put up a great tutorial on how to drive shift registers with an SPI interface. Give it a try, it’s a fun experiment! Posted in Microcontrollers Tagged 74hc165, input, rc, shift register Controlling Shift Registers Via SPI In between clock pulses, the microcontroller switches from output to input to read the data pin on each cycle. The data pin has an added resistor, which keeps the current low enough that it will not compete with the clock signal coming from the microcontroller. Notice that the clock and data pins are now connected to just one of the microcontroller pins. It’s the same as using SPI to drive 595 shift registers except the microcontroller reads data instead of writing it.īut wait, there’s more! The diagram above actually shows a way of reading this shift register with just one pin. You can still use hardware SPI to read the data using this method. This technique drops the control down to just two pins (data and clock). The addition of a carefully trimmed RC circuit (capacitor is charged by the clock pin, then the resistor lets that cap slowly discharge) means that the device will not latch until after the clock stops toggling. This hack first does away with the latch pin. For those counting, that’s the three pins normally associated with driving these devices. They have a parallel input register which can be read using the latch, then shifted into a microcontroller via the data and clock pins. 74HC165 shift registers are a popular choice for adding inputs to a microcontroller. Here’s an interesting article about reading data from shift registers using less than three pins.