Blogroll

Powered by Blogger.

Tuesday 26 August 2014

Circuit and Program to Control 74HC595 / 74HCT595 using Arduino Mega

by realfinetime  |  in Electronics at  21:21

<< Read Previous Page
   
          We have already seen that, arduino get damaged if 16 control pins of LED matrix is directly connected to the 16 digital output pins of arduino because of the large current drawn from arduino board. Our next aim is to reduce the number of digital pins required to control LED matrix.

          A simple and effective method is using shift registers. Shift register IC used for our purpose is 74HC595. This tutorial is to make you an expert in this project quickly. So the timing diagram is not going to explain in this blog. If you want to read more about 74595, get the PDF from here. All other details such as voltage rating, limiting values, recommended operating conditions and timing diagram is clearly explained in the datasheet.

          Circuit is done as given in the following diagram. Q0 - Q7 are the output pins and is connected to individual LEDs as shown in the diagram through current limiting resistors of 1K each. Q7' is left unconnected in this case. This is serial data output and is given as serial data input to the next 74595. 5V for the working of 74595 is given from a 5V regulator. MRbar should be connected to the VCC pin of 74595. OEbar should be connected to the Gnd pin of 74595. DS, STCP and SHCP is given from arduino in this case. SHCP of 74595 is connected to the digital pin 13 of arduino. STCP of 74595 is connected to the digital pin 12 of arduino and DS pin of 74595 is connected to the digital pin 13 of arduino.
Program to shift out number 1 to 74595 in MSBFIRST order

Now upload the following program to your arduino board.

//Pin connected to ST_CP of 74595
int latchPin = 12;
//Pin connected to SH_CP of 74595
int clockPin = 13;
////Pin connected to DS of 74595
int dataPin = 11;

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {

    int ShiftOut_value = 1;
    // take the latchPin low so     // the LEDs don't change while you're sending in bits:     digitalWrite(latchPin, LOW);     // shift out the bits:     shiftOut(dataPin, clockPin, MSBFIRST, ShiftOut_value);
    //take the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
}

Output:

Q0 will turn on, all others will turn off.

Q0   Q1   Q2   Q3   Q4   Q5   Q6   Q7

 1      0      0      0      0      0      0      0


Program to shift out number 2 to 74595 in MSBFIRST order

Upload the following program to your arduino board.

//Pin connected to ST_CP of 74595
int latchPin = 12;
//Pin connected to SH_CP of 74595
int clockPin = 13;
////Pin connected to DS of 74595
int dataPin = 11;

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {

    int ShiftOut_value = 2;
    // take the latchPin low so     // the LEDs don't change while you're sending in bits:     digitalWrite(latchPin, LOW);     // shift out the bits:     shiftOut(dataPin, clockPin, MSBFIRST, ShiftOut_value);
    //take the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
}

Output:

Q1 will turn on, all others will turn off.

Q0   Q1   Q2   Q3   Q4   Q5   Q6   Q7

 0      1      0      0      0      0      0      0


Program to shift out number 3 to 74595 in MSBFIRST order

Now upload the following program to your arduino board.

//Pin connected to ST_CP of 74595
int latchPin = 12;
//Pin connected to SH_CP of 74595
int clockPin = 13;
////Pin connected to DS of 74595
int dataPin = 11;

void setup() {
  //set pins to output so you can control the shift register
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop() {

    int ShiftOut_value = 3;
    // take the latchPin low so     // the LEDs don't change while you're sending in bits:     digitalWrite(latchPin, LOW);     // shift out the bits:     shiftOut(dataPin, clockPin, MSBFIRST, ShiftOut_value);
    //take the latch pin high so the LEDs will light up:
    digitalWrite(latchPin, HIGH);
}

Output:

Q0 and Q1 will turn on, all others will turn off.

Q0   Q1   Q2   Q3   Q4   Q5   Q6   Q7

 1      1      0      0      0      0      0      0

Read the remaining in next page.

2 comments:

  1. You can choose between active and passive buzzer? Here https://nerdytechy.com/active-vs-passive-buzzer/ you can understand differences!

    ReplyDelete
  2. Here you can find the best bluetooth modules for Arduino

    ReplyDelete

IMPORTANT NOTICE

All the circuits, published in this blog is only after testing and getting proper results in my private lab. When you try these circuits, you should check the supply voltage, polarity of components, presence of childrens nearby and shorts in the circuits. This website will not be responsible for any harm happened to you or your components caused by your carelessness.

For More Electronic Tips



Blog Archive

Proudly Powered by Blogger.