Maneuvering the LEDs (using 74HC595 Shift Register) CloudX

  • img
Project Details


Nota Bene



Let's learn how to control the LEDs ON and OFF states using an IC (Integrated Circuit) chip known as shift-register IC. Here, we’ll be making use of the 74HC595 shift register IC to maneuvre the logic states of the individual members of array of LEDs.  The circuit connection is simple enough to implement; and we’ll be using the breadboard and a simple CloudX code to realize the project.

Meanwhile ─so far, we've learned how: to blink a simple LED via CloudX's output, to use a switch to control LED on and off states via CloudX digital input and to use LED 7-segment display.In this lesson, we'll control the ON and OFF states of an array of LEDs to create some special effects called LED chaser pattern on our display. 


List Of Materials Needed 

(The material full kit can readily be sourced via this link.)

(i)    CloudX Microcontroller and Softcard 

(ii)    74HC595 Shift Register IC

(iii)   8 LEDs 

  • (iv)   8 Resistors (any value from 100Ω – 1kΩ)






                  Step 1: Hints and Brief Overview


Shift-Registers are used for data storage or for the movement of data. 


  • (i)  They are used in say calculators or computers to hold data such as mathematical operands before they are added together.
  • (ii)  They aid in converting data from either a serial to parallel or parallel to serial format.


They (shift-registers) can generally operate in one of the following four modes:

  2. 1.)  Serial-In to  Parallel-Out (SIPO)
SIPO mode


2.)  Serial-In to Serial-Out (SISO

SISO mode


3.)  Parallel-In to Serial-Out (PISO)

PISO mode

4.)  Parallel-In to Parallel-Out (PIPO)

PIPO mode



The 74HC595 Shift-Register Chip   

It uses SIPO Mode of Operation.

74hc595 shiftregister IC



                              Step 2: Build The Circuit






As shown in the schematic diagram above, the shift-register chip pins: 11, 14 and 12, interface with the microcontroller pins: P1, P2 and P3, respectively. The chip output pins: 15, 1, 2, 3, 4, 5, 6, and 7, connect up to the LEDs via their respective current limiting resistors.

The IC Output Enable Pin (pin 13) should be tied fixed to Ground (0V) since it is an active-low pin. When properly connected, its function is to ensure that the chip output pins are activated.

Likewise, the IC Memory Reset Pin (pin 10) should be fixed at VCC to deactivate any memory clear operation whatsoever.

Power can be sourced to the board either via the USB Softcard; or via connecting an external power supply (between 7 – 12 VDC) to the VIN pin of the microcontroller board.

Pin-Out Table



                      Step 3: Build The Source Code

The program reels out like this :




Let’s attempt to expatiate on the code a little bit more:

Here, we’re utilizing 74HC595 Shift Register Library to simplify things for ourselves.

The special-effect pattern emanates basically from the below lines in the loop section:

  • (i)     the shift-right data manipulation as thus:
     mask = dataByte >>i;
  • (ii)     the shift register function-calls:

         HC595_shiftOut(mask, LSBFIRST);
         HC595_shiftOut(mask, MSBFIRST); 


The parameters include:

  • (i)    Data to be displayed
  • (ii)    The order the bits of the data are to be serially entered into the shift register


                      -  LSBFIRST means Least Significant Bit First

                      -  MSBFIRST means Most Significant Bit First


Likewise playing around with the delay duration (ie. varying it) also has its own characteristic effect on the display.

In essence, you are hereby encouraged to also attempt your own desired styles, and try to see for yourself the many beautiful effects you can possibly get too.


                          Step 5: Compile The Code

At this point, we’re simply good to go as to compiling the source code to obtain our hex file that is to be burnt into the microcontroller later on.

For further details on how to compile the code into an executable (hex) file, you can refer to this link.


                      Step 6: Load In The Hex Code File

Now, it is really time to get our project fully prepared to power up. The already obtained hex file is loaded into the microcontroller. 

For further details on how to burn in the code to the microcontroller, you can refer to this link.


                        Step 7: Power Up The Project

The project is finally powered on, and it comes alive as specified in our design.




Wow, we’re really making some significant progress already! Now we’ve learnt how to control the LEDs using the shift-register chip; let’s try to expand it (the knowledge) to what more display-effects we can possibly get maneuvering the LEDs. It’s definitely getting more interesting here as we want to use yet another LED display called the Dot-Matrix LED Display. So, continue on to the next lesson as we make further attempts at expanding our embedded systems design knowledge using CloudX.




Copy the code

#include <CloudX/74HC595.h>  

char data, mask;
char i; 

    //setup here 
    //Initialize the Shift Register
    HC595_setting(1, 2, 3);         //DAT,CLK,LAT 
    data = 0xE0; 
        //Program here 
        for(i = 0; i < 8; i++) 
            mask = data >>i;  //shifts value in data to the 
                              //right by “i” and load in mask
            //This function-call loads content of mask into shift 
            //register from the LSB up to the MSB. 
            HC595_shiftOut(mask, LSBFIRST); 
            HC595_latch();   //changes shift output to match the
                             //data received(mask) 

            delayMs(500);    //keeps shift output for half a
            //This function-call loads content of mask into shift 
            //register from the MSB up to the LSB. 
            HC595_shiftOut(mask, MSBFIRST); 
            HC595_latch();  //changes shift output to match the
                            //new data received 


Share this with friends