Arduino Tutorial 4 : 8 LEDs and a Shift Register

Hello all ! Today in this blog we will discuss about how to control 8 LED’s using Arduino and a shift register through programming. Arduino is an open source electronic platform based on easy to use hardware and software.

Please support us on YouTube also. Like Share and Subscribe to our channel :


Circuit Diagram


Shift Register

Here we have used Serial-In-Parallel-Out shift register IC 74HC595. We can control any number of output pins using only 3 input pins of shift register called Data, Clock and Latch. Here we have used 8 number of LED’s so we would have needed 8 number of input pins but no we can control these 8 LED’s using only 3 input pins of shift register.



Arduino Tutorial - Lesson 4. 8 LEDs and a Shift Register
int dataPin = 4; //shift register pin14
int clockPin = 5; //shift register pin11
int latchPin = 6; //shift register pin12

byte leds = 0;

void setup() 
  pinMode(latchPin, OUTPUT);
  pinMode(dataPin, OUTPUT);  
  pinMode(clockPin, OUTPUT);

void loop() 
  leds = 0;
  for (int i = 0; i < 8; i++)
    bitSet(leds, i);

void updateShiftRegister()
   digitalWrite(latchPin, LOW);
   shiftOut(dataPin, clockPin, LSBFIRST, leds);
   digitalWrite(latchPin, HIGH);

Code to Note

pinMode(4, OUTPUT) – You have to tell ARDUINO that PIN4, PIN5 and PIN6 are used as Output or Input. so, here we used the built in function called pinMode().

updateShiftRegister() – Shift Register has 8 Bits so every time we have to send 8 Bits data to 74HC595 Shift Register IC through Arduino using built in function bitset(). Before sending these 8 Bits data to 74HC595 IC we have to triggered the Latch pin to LOW and after sending these 8 Bits data we have to triggered the Latch pin to HIGH.


In this program 8 LED’s glowing one by one gradually. Similarly we can also reprogram the ARDUINO and change the rate at which it glows.

Further Readings

If you liked this article, then please subscribe to our YouTube Channel. You can also find us on InstagramFacebook and Twitter.