Shift Register LED – Playing with a Shift Register and LEDs


Building on this question, I've now got a shift register to play with, and I've been trying to work it manually with a couple of switches, like so:
shift register LED array

I have resistors (2.2K) between the switches and VCC, even though that's not shown in the schematic. It doesn't work, though.

When I press the clock switch, sometimes an LED will light, and sometimes it won't. Sometimes several LEDs light. Never does it "shift" a zero "bit". If I just hit the input switch a bunch of times, it shifts in bits, sometimes one at a time, sometimes several at a time.

What gives? What have I done wrong here?

Best Answer

The switch is "bouncing": Each time you open or close it, there is a period where it makes a bit of noise on the clock line. The chip sees this noise as multiple transitions and clocks in more bits than you intended. To fix this, you need a "debouncing" circuit. Google should find you something.


You can't just switch voltage to an input like that. Then the input is at +5V when the switch is closed, but floating when the switch is open. You need at least a pulldown resistor after the switch.