Can You Feel It Shifting In The Air Tonight

A project log for Shift Register Menorah

A byte-sized wearable menorah pin with eight settable flickering lights

stephSteph 12/07/2023 at 02:400 Comments

Nice Bits!

A shift register is perhaps most commonly used to drive a seven-segment display:

It's the sort of display that you might find in a clock or in a DeLorean. Naturally, a seven-segment display does not actually have seven segments. Including the decimal point, it actually has eight. Which conveniently is exactly the number we need for a fully functional menorah! Of course, our shift register has a higher calling than blinking "12:00" on an some old VCR.

The 74HC595 shift register used to light the LEDs in this menorah is located here on the left side of the board:

How It Works

The shift register has (basically) two inputs, and eight outputs. The two inputs we care about are "data" and "clock." For every pulse from low to high on the clock pin, the shift register samples the data pin, and shifts this value into the first slot on the register. Each of the eight slots are tied to eight LEDs. 


Basically, think Skee-Ball:

...wherein each of these balls represent a high or low bit filling up the register.

With every clock cycle, a ball is removed from the bottom, another is added to the top, and all the balls shift down. In this analogy, there are "on" balls and "off" balls, and these balls control our LEDs.

In our circuit, power is first applied by pushing the button and activating the MOSFET. This immediately turns on the shift register, which actually powers on into an unknown, random state. Or if you prefer analogy: the Skee-Ball machine is filled with random balls. 

At this moment in time, when the power button has been depressed but not yet released, any of the 8 LEDs may be lit. As soon at the button is released, the chip clears its register and displays zero lit LEDs. 

In other words, the Skee-Ball machine flushes out all the random balls and refills itself with "off balls."

From then on the data line is always high, meaning we'll be filling up our machine with "on" balls. Every time you cycle the clock by pushing the button, you are basically removing one "off" ball from the bottom of the Skee-Ball rack, and adding one "on" ball to the top. 

As demonstrated by Lisa and Maggie in the above gif, every "on" ball in the shift register causes a new LED to light.

Once the register is full of "on" balls our menorah will be fully lit:

At this point, additional clicks of the button continue to feed new "on" balls into the top of the register and the old "on" balls continue getting removed from the bottom of the register. None of this is visually apparent as all the lights on the menorah are already lit. 

To extinguish them, a long press of the button powers off the whole circuit. If you're playing by the rules, the candles should be put out thirty minutes after nightfall!