Blogroll

Powered by Blogger.

Wednesday 24 September 2014

Display 1, 2 and 3 in 1st, 2nd and 3rd SSDs using Arduino and 74595 (Part 16 of 16)

by realfinetime  |  in Seven Segment Display at  03:16

<<<< Read Previous Part (Part 15)

          We have found the circuit for controlling a cluster of 8 common cathode seven segment displays using arduino and 74595 in previous blogs. Click here to start reading from the beginning of "controlling a cluster of eight common cathode seven segment displays using arduino and 74595".

          Here, we will generate an arduino program that will display "1.", "2." and "3." in first, second and third common cathode seven segment displays as given below.


Circuit is given here. Complete that circuit and upload the following program to your arduino board.

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

int latchPin2 = 6;  //Pin connected to ST_CP of 2nd 74595
int clockPin2 = 7;  //Pin connected to SH_CP of 2nd 74595
int dataPin2 = 5;  //Pin connected to DS of 2nd 74595

int i=0;

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

void loop() {

  /*************** DISPLAYS NUMBER 2 **************/ 
  for(i=0;i<2;i++)  //Increase the brightness of LEDs
  {
    // take the latchPin low so the LEDs don't change while you're sending in bits:     
    digitalWrite(latchPin, LOW);
    //Send 1 0 0 0 0 1 1 0 (134) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
    shiftOut(dataPin, clockPin, MSBFIRST, 134);
    // shift out the bits:    
    digitalWrite(latchPin, HIGH);
          
    // take the latchPin low so the LEDs don't change while you're sending in bits:    
    digitalWrite(latchPin2, LOW);
    //Send 1 1 1 1 1 1 1 0 (254) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
    shiftOut(dataPin2, clockPin2, MSBFIRST, 254);
    // shift out the bits:  
    digitalWrite(latchPin2, HIGH); 
    
  }
  
  /********* Turn off all the LEDs *********/
    
  // take the latchPin low so the LEDs don't change while you're sending in bits:    
  digitalWrite(latchPin2, LOW);
  //Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
  shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
  // shift out the bits:  
  digitalWrite(latchPin2, HIGH); 

  /*************** DISPLAYS NUMBER 2 **************/ 
  for(i=0;i<2;i++)  //Increase the brightness of LEDs
  {
    // take the latchPin low so the LEDs don't change while you're sending in bits:     
    digitalWrite(latchPin, LOW);
    //Send 1 1 0 1 1 0 1 1 (219) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
    shiftOut(dataPin, clockPin, MSBFIRST, 219);
    // shift out the bits:    
    digitalWrite(latchPin, HIGH);
          
    // take the latchPin low so the LEDs don't change while you're sending in bits:    
    digitalWrite(latchPin2, LOW);
    //Send 1 1 1 1 1 1 0 1 (253) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
    shiftOut(dataPin2, clockPin2, MSBFIRST, 253);
    // shift out the bits:  
    digitalWrite(latchPin2, HIGH);  
  }
  
  /********* Turn off all the LEDs *********/
    
  // take the latchPin low so the LEDs don't change while you're sending in bits:    
  digitalWrite(latchPin2, LOW);
  //Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
  shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
  // shift out the bits:  
  digitalWrite(latchPin2, HIGH); 
 
  /*************** DISPLAYS NUMBER 3 **************/
  for(i=0;i<2;i++)  //Increase the brightness of LEDs
  {
    // take the latchPin low so the LEDs don't change while you're sending in bits:     
    digitalWrite(latchPin, LOW);
    //Send 1 1 0 0 1 1 1 1 (207) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595
    shiftOut(dataPin, clockPin, MSBFIRST, 207);
    // shift out the bits:    
    digitalWrite(latchPin, HIGH);
          
    // take the latchPin low so the LEDs don't change while you're sending in bits:    
    digitalWrite(latchPin2, LOW);
    //Send 1 1 1 1 1 0 1 1 (251) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
    shiftOut(dataPin2, clockPin2, MSBFIRST, 251);
    // shift out the bits:  
    digitalWrite(latchPin2, HIGH); 
    
  }
  
  /********* Turn off all the LEDs *********/
    
  // take the latchPin low so the LEDs don't change while you're sending in bits:    
  digitalWrite(latchPin2, LOW);
  //Send 1 1 1 1 1 1 1 1 (255) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595
  shiftOut(dataPin2, clockPin2, MSBFIRST, 255);
  // shift out the bits:  
  digitalWrite(latchPin2, HIGH);     
}


          "1.", "2." and "3." will be displayed in the first, second and third common cathode seven segment displays. All other seven segment displays will turn off.

Working of program

          Working of program is simple. Program will send 134 (1 0 0 0 0 1 1 0) to the first 74595. Then Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of first 74595 becomes 1 0 0 0 0 1 1 0. After that, program will send 254 (1 1 1 1 1 1 1 0) to second 74595. Then, Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of second 74595 becomes 1 1 1 1 1 1 1 0. This will turn on b, c and dp segments of first common cathode seven segment display and turn off all other seven segment displays as given in this part. When b, c and dp segments of a seven segment display is on "1." will be displayed in the seven segment display.

          After displaying these, arduino will send 255 (1 1 1 1 1 1 1 1) to the second 74595 to turn off all the seven segment displays.

          Then, program will send 219 (1 1 0 1 1 0 1 1) to the first 74595. Then Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of first 74595 becomes 1 1 0 1 1 0 1 1. After that, program will send 253 (1 1 1 1 1 1 0 1) to second 74595. Then, Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of second 74595 becomes 1 1 1 1 1 1 0 1. This will turn on a, b, d, e, g and dp segments of second common cathode seven segment display and turn off all other seven segment displays as given in this part. When a, b, d, e, g and dp segments of a seven segment display is on "2." will be displayed in the seven segment display.

          After displaying these, arduino will send 255 (1 1 1 1 1 1 1 1) to the second 74595 to turn off all the seven segment displays.

          Then, program will send 207 (1 1 0 0 1 1 1 1) to the first 74595. Then Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of first 74595 becomes 1 1 0 0 1 1 1 1. After that, program will send 251 (1 1 1 1 1 0 1 1) to second 74595. Then, Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of second 74595 becomes 1 1 1 1 1 0 1 1. This will turn on a, b, c, d, g and dp segments of third common cathode seven segment display and turn off all other seven segment displays as given in this part. When a, b, c, d, g and dp segments of a seven segment display is on "3." will be displayed in the seven segment display.

          After displaying these, arduino will send 255 (1 1 1 1 1 1 1 1) to the second 74595 to turn off all the seven segment displays.

Principle of Operation

          Display works based on the principle of "persistence of vision". Only one number will be displayed at a time (1. or 2. or 3.). "1." will be displayed first. Then, entire display will turn off  and "2." will be displayed. Entire display will be turned off again and "3." will be displayed. After displaying "3.", display will be turned off and "1." will be displayed again. These processes takes place within 1/16th part of a second which will give an illusion to our eyes that "1.", "2." and "3." are displaying together.

Next : Design a Pattern in Seven Segment Display Cluster  >>>>

0 comments:

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.