E Shore Technologies - Online Robotic Center

  • Increase font size
  • Default font size
  • Decrease font size
Home All Projects Control LEDs Using Shift Register IC 74HC595


Control LEDs Using Shift Register IC 74HC595

E-mail Print PDF

Under this article, we will be controlling 8 LEDs using Shift Register IC 74HC595 (Quick Reference for 74HC595 here).

090820112717

74HC595 is a Shift Register IC, that we can use it to expand limited Microcontroller output pin. We can use minimum of 3 output pin from Microcontroller to control the Shift Register IC (DS, SHCP and STCP) and we can have total of 8 output pin from from the Shift Register IC. In the other words, it is a serial (3 pin) to parallel (8 pin) converter that allows us to expand output pins from 3 pin to unlimited output pin. Connecting these Shift Register IC in series we can have more that 8 pin output, for example, using 5 x Shift Register IC, we can expand the output pin from 3 pin to 40 pin (5 x 8 pin). We will never be out of output pin anymore!

74HC595 Basic

090820112697

image

image

The basic operation to shift out 8-bit data to a 74HC595:

  1. Shift the 8-bit data to the 8-bit Storage Register through DS and SHCP pin (Serial Data and Serial Clock pin)
  2. Apply a pulse to STCP pin to shift the data from 8-bit Storage Register to 3-State Output Register (the 8 pin Parallel Output)

OE pin - the Output Enable pin that control the 3-State Output to either enable/activate the output (output = value of 3-State Output Register) or disable/deactivate the output (output = high impedance state).

MR pin - the Master Reset pin that clear the whole 8 Stage Shift Register Output.

Q7S pin - is the Serial Data Output that will be connected to the Serial Data Input pin of the next 74HC595 when they are connected in series (Daisy Chain)

Schematic

image

Arduino Digital Pin2 will be connected to DS, Pin3 to SHCP and Pin4 to STCP pin on 74HC595. All LEDs will be connected to the Output Q0 - Q1 from 74HC595. OE pin connected to GND to always enable all output, MR pin connected to 5V to always enable the Shift Register.

090820112702

090820112705

090820112711

090820112709

Coding

You can download the full code at the end of this article.

//=======================================================================    
//  Control LEDs using Shift Register IC 74HC595     
//  (2011 August)     
//  www.e-shore.com.my     
//=======================================================================     
  
//Shift Register Pins     
const int DS=2;     
const int SHCP=3;     
const int STCP=4;     
  
//  setup function     
//=======================================================================     
void setup()     
{     
  //configure all Shift Register Pins as output     
  pinMode(DS,OUTPUT);     
  pinMode(SHCP,OUTPUT);     
  pinMode(STCP,OUTPUT);     
  
  //clear all pin as default     
  digitalWrite(DS,LOW);     
  digitalWrite(SHCP,LOW);     
  digitalWrite(STCP,LOW);     
}     
  
//  loop function     
//=======================================================================     
void loop()     
{     
  //variable     
  static int counter=0;     
  
  counter+=1;                          //increase counter     
  shiftOut(DS,SHCP,MSBFIRST,counter);  //shift out counter value to 74HC595     
  digitalWrite(STCP,HIGH);             //shift out data from 8-bit Storage     
  digitalWrite(STCP,LOW);              //Register to 3-State Output     
  
  delay(50);                           //50ms delay     
}

The code for the project is quite simple, at the beginning of the coding, we will need to declare or define the pin use for Shift Register accordingly (DS=2, SHCP=3, and STCP=4). Under setup function, configure all the Shift Register pin as output, and set the output to LOW by default. Under loop function, we will create an int variable called counter, (use static keyword to make the value of the counter remain even after the loop function is exited). This counter variable will be increase each time the loop function is executed. Then, we will use shiftOut function to shift out the value of counter to 74HC595.

image

Remember that the shiftOut function will only shift out the data to 74HC595 8-bit Shift Register but the data will not shown on the output pins. We will need to send a pulse at STCP pin to channel or shift out the data we sent to output pin. Please take note that the minimum pulse width for STCP is around 22ns (for 4.5V VCC), which means that we don’t need to apply delay between setting and clearing the STCP pin. After sending pulse at STCP, we will perform a 50ms delay so that we can see the changes on the LEDs.

Attachments:
FileFile size
Download this file (Control_LEDs_using_Shift_Register_IC_74HC595.zip)Control LEDs using Shift Register IC 74HC5950.9 Kb
 

Comments  

 
#3 mi favorita 2014-10-30 09:25
 Casi Toda la info aparece scrita de guisa directa y inmediata.
El presente portal resulta ser de lo mas bueno que he podfido encontrar en la mayor parte
de internte. Felicitaciones.

Comprueba y puedes navega poor mi homepage: mi favorita: http://ijhsshangout.com/index.php?do=/profile-4399/info/
Quote
 
 
#2 FIFA 15 Download 2014-09-14 13:26
Down load FIFA 15 Total Online game + Bust
FIFA 15 can be an forthcoming online game which is launched with Sept 26th by
means of EA Game titles. We now have managed to Down load FIFA 15 from EA machines as well as made it possible to create a FIFA 15 Bust just by a person men.
When you Down load FIFA 15 Entire Sport + Split through each
of our internet site we are able to guarantee that you will possess the
very same high quality of item since those people individuals who have ordered FIFA 15.
That’s due to the fact the FIFA 15 Fracture provides each
of the highlights of enthusiasts format of FIFA 15 jailbroke
already. Because most of us appreciate an individual much!


Here is my web-site ... FIFA 15 Download Free: http://www.traccedicibo.com/2009/08/spiedini-prosciutto-melone-e-primosale.html
Quote
 
 
#1 exersizze 2011-09-24 16:13
hi! algorithm of 74hc595
http://avrproject.ru/74hc595/74hc595.gif
Quote
 

Add comment


Security code
Refresh

Login/Register

E-Mail Address:

Password:


Find us on Facebook



Sponsored Links