Introduction: 8-LED Knightrider: Using Shift Registers With Arduino

A shift register comes in handy when you require more output pins than what your Arduino offers. Simply put, shift registers can be used to increase the number of output pins in your microcontroller. Theoretically speaking, you can make infinite number of output ports cascading these shift registers which would only require 3 Arduino pins to control them.

In this instructable we will use a 8-bit shift register( 74HC595 ) with an Arduino to make a Knightrider or LED scanner.This uses three Arduino output pins to control the 8 LED's.

Step 1: Components Required

You'll need the following components:
  1. 8-bit shift register ( 74HC595 )
  2. LED's ( x 8 )
  3. 220 ohm resistor ( x 8 )

and of course a breadboard and an arduino :P

Step 2: Shift Registers Pins

Coming straight to the point, the three pins of the HC595 which are controlled by the Arduino are

  • Clock pin (pin 11): Connected to Arduino pin 12
  • Latch pin (pin 12): Connected to Arduino pin 8
  • Data pin(pin 14) : Connected to Arduino pin 11

The functions of these three pins are explained along with the code.

The output pins of the shift register are : pin 15 and pin 1 - pin 7.

Pin 10 is serial clear which is active low, hence is connected to +5 V from Arduino to disable the pin.

Pin 13 is output enable which is also active low hence is connected to the ground to enable the pin.

Step 3: Circuit Diagram

NOTE: Don't forget the resistors or you may end up blowing all your LED's.

Step 4: Code

The Arduino code is simple yet i'll give a brief explanation. The latch pin works like a dam. When it is pulled LOW the data is contained in the register just like water is contained in a reservoir. While the latch is pulled HIGH all the data stored is released through the output pins (Q0-Q7) just like water is released from a reservoir when the dam is opened.

int clock= 12;//IC pin 11 (yellow)
int latch=8;//IC pin 12 (green) int data=11;//IC pin 14 (blue)

byte pattern[]=
{ B00000001, B00000010, B00000100, B00001000, B00010000, B00100000, B01000000, B10000000, B01000000, B00100000, B00010000, B00001000, B00000100, B00000010 }; int index =0; int count=sizeof(pattern); void setup() { pinMode(clock,OUTPUT); pinMode(latch,OUTPUT); pinMode(data,OUTPUT); } void loop() { digitalWrite(latch,LOW); shiftOut(data,clock,MSBFIRST,pattern[index]); digitalWrite(latch,HIGH); delay(100); index++; if(index>=count) index=0; }

Step 5: Animation/Video

View the animation at


Circuits Contest 2016

Participated in the
Circuits Contest 2016