Sometimes we have number of modules to connect over our arduino, but arduino have 14 digital I/O pins, to avoid this problem we can use shift register IC.

Shift register IC is like a 3 inputs and 8 pin digital outputs decoder, where we use three pins of arduino for our signal that will be fed to three input lines of IC and from the output of IC we can decode it back.



  • Pins 15,1,2,3,4,5,6,7 are eight digital output pins labeled as Q0 to Q7
  • Pin 8 connect to ground
  • Pin 9 is data out and used when we have to connect another shift register
  • Pin 10 to +5 V of arduino always
  • Pins 11 and 12 are clock and latch
  • Pin 13 is output enable connect it to ground
  • Pin 14 for incoming byte data sent from arduino
  • Pins 16 to +5V of arduino always


How Shift Register IC works? We send 1 byte (8 bits) on data from our arduino like 11000001, then we will see 3 pins of IC are HIGH and & are 5 LOW.

Now the question arises. Which pins are to be High and which to be LOW?

As the bits represent data of byte variable, showing logics high and low, are responsible for output pin in an order. Where left most bit (Most significant bit MSB) is for output Q7 and right most bit (Least significant bit LSB) is for output Q0 i.e. highest to lowest. Suppose, if the byte signal is B11001100 then the output of pins are

Decimal Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0
204 1 1 0 0 1 1 0 0
2 – MSB, 4 – LSB MSB LSB

till next cycle of byte. But we can change the orientation of MSB & LSB through programming we will see next (Here 1 represents High & 0 represents Low)

Lets connect 8 led to shift register IC to display 0 – 255 binary numbers pattern and to control them using only 3 data pins (digital) of arduino.

Make this circuit diagram

Arduino Interfacing with Shift Register IC 74HC595

LED Binary Number Display

In this we will pass a number of decimal number system and display its binary in the form of let. For example number is 14 & its 8-bit binary equivalent is B00001110 then we will see first 4 led’s OFF and then 3 led’s ON and then last led OFF as well.

We know highest 8-bit binary number is B11111111 and its equivalent decimal number is 255. So we are going to display all numbers turn by turn from 0 to 255.

After making this circuit upload the sketch given below:


// Creating an LED Binary Number Display
#define DATA 6      // digital 6 to pin 14 on the 74HC595
#define LATCH 8     // digital 8 to pin 12 on the 74HC595
#define CLOCK 10    // digital 10 to pin 11 on the 74HC595
int i = 0;
void setup() {
  pinMode(LATCH, OUTPUT);
  pinMode(CLOCK, OUTPUT);
  pinMode(DATA, OUTPUT);
void loop() {
  for ( i = 0; i < 256; i++ ) {
    digitalWrite(LATCH, LOW);
    shiftOut(DATA, CLOCK, MSBFIRST, i);
    digitalWrite(LATCH, HIGH);


  1. First of all we are defining three pins DATA, LATCH & CLOCK as 6, 8 & 10 respectively and a variable i of int data type and initialize as 0.
  2. Setup
    1. We simply set all three pins as OUTPUT, main logic is inside loop
  3. Loop
    1. A for loop runs from 0 to 255 for i
    2. Then LATCH pin is set to LOW
    3. Then using a function shiftOut(),

In shiftOut() function we have to pass 4 arguments of integer type, 1st one data pin i.e. from which arduino pin data to transit over shift register IC, 2nd which pin is used as clock, 3rd interrupt direction, then what is data, here is i the data number from 0 to 255.

We send a decimal number from arduino to shift register IC in binary form, for example 240 as B11110000 from arduino digital pin 6 and tells the shiftOut() function from which direction to interrupt the signal byte either LSB or MSB

  1. If LSBFIRST selected, then D7 (bit) denotes the Q0 (pin of shift register IC)
  2. If MSBFIRST selected, then D7 (bit) denotes the Q7 (pin of shift register IC)
  1. Then finally set Latch pin as HIGH, this tells shift register that bits are shifted and ready, at this point it vanishes previous output and update new data.
  2. End the cycles repeats every half second or 500 millisecond
  3. After completion of for loop again loop starts from the beginning i.e. from 0 to 255.



Leave a Reply

Notify of

Arduino Tutorials with Basic Electronics: CONTENT

Translate »