Before I go through the code, let's have a quick look at what the chip is doing, so that we can understand what the code has to do.

The chip is of a type called a shift register.

The shift register holds what can be thought of as eight memory locations, each of which can be a 1 or a 0.

To set each of these values on or off, we feed in the data using the 'Data' and 'Clock' pins of the chip.

The clock pin needs to receive eight pulses. At the time of each pulse, if the data pin is high, then a 1 gets pushed into the shift register. Otherwise, it is a 0. When all eight pulses have been received, then enabling the 'Latch' pin copies those eight values to the latch register. This is necessary, otherwise the wrong LEDs would flicker as the data was being loaded into the shift register.

The chip also has an OE (output enable) pin, this is used to enable or disable the outputs all at once. You could attach this to a PWM capable Arduino pin and use 'analogWrite' to control the brightness of the LEDs. This pin is active low, so we tie it to GND.

This guide was first published on Dec 03, 2012. It was last updated on Mar 08, 2024.

This page (The 74HC595 Shift Register) was last updated on Mar 08, 2024.

Text editor powered by tinymce.