<<<< Previous : Control 8 Seven Segment Displays using Arduino and 74595
In the past few blogs, we had seen the logic behind accessing and displaying numbers on various seven segment displays in a cluster of 8 common cathode seven segment displays. Here, we will design a pattern as shown below.
Circuit is given here. Complete that circuit. Copy and upload the following program to your arduino board.
If uploading is successful, pattern will be displayed in the cluster of common cathode seven segment displays. Speed of pattern can be adjusted by changing the upper limit of "k" loop.
Circuit is given here. Complete that circuit. Copy 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,k=0, j=0,l=0; int cathode_terminal_array[]={254, 253, 251, 247, 239, 223, 191, 127}; int anode_terminal_array[]={131, 194, 208, 152, 140, 196, 224, 161}; 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() { for(l=0;l<8;l++) // Loop to access the "anode_terminal_array" elements { for(k=0;k<15;k++) //Loop to adjust the speed of illumination { for(j=0;j<8;j++) // Loop to access the "cathode_terminal_array" elements { for(i=0;i<2;i++) // Loop to increase the brightness of Display { // take the latchPin low so the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); shiftOut(dataPin, clockPin, MSBFIRST, anode_terminal_array[l]); // 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); shiftOut(dataPin2, clockPin2, MSBFIRST, cathode_terminal_array[j]); // 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); } } } }
If uploading is successful, pattern will be displayed in the cluster of common cathode seven segment displays. Speed of pattern can be adjusted by changing the upper limit of "k" loop.
0 comments: