<<<< Read Previous Part (Part 14)
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." and "2." in first and second common cathode seven segment displays as given below.
Circuit is given here. Complete that circuit and upload the following program to your arduino board.
"1." and "2." will be displayed in the first and second 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.
Principle of Operation
Display works based on the principle of "persistence of vision". Only one number will be displayed at a time (either 1. or 2.). "1." will be displayed first. Then turn off the entire display. After that, "2." will be displayed within 1/16th part of that second at which "1." was displayed which gives an illusion to our eyes that "1." and "2." are displaying together. Then turn off the entire display and "1." will be displayed again. "1." will be displayed within 1/16th part of that second at which "2." was displayed.
Here, we will generate an arduino program that will display "1." and "2." in first and second 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); }
"1." and "2." will be displayed in the first and second 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.
Principle of Operation
Display works based on the principle of "persistence of vision". Only one number will be displayed at a time (either 1. or 2.). "1." will be displayed first. Then turn off the entire display. After that, "2." will be displayed within 1/16th part of that second at which "1." was displayed which gives an illusion to our eyes that "1." and "2." are displaying together. Then turn off the entire display and "1." will be displayed again. "1." will be displayed within 1/16th part of that second at which "2." was displayed.
Continued in Next Part (Part 16) >>>> |
0 comments: