<<<< Previous : Design an Amazing Pattern in Seven Segment Display Cluster
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 create an arduino program that will generate scrolling numbers in a cluster of 8 common cathode seven segment displays.
Circuit is given here. Complete that circuit. Program for generating scrolling numbers is given below. Copy the program and upload it to your arduino board.
If uploading is successful, scrolling numbers will be generated in the seven segment displays. Speed of scrolling can be adjusted by changing the upper limit of "k" loop. Brightness of LEDs can be adjusted by changing the upper limit of "i" loop.
Here, we will create an arduino program that will generate scrolling numbers in a cluster of 8 common cathode seven segment displays.
Circuit is given here. Complete that circuit. Program for generating scrolling numbers is given below. Copy the program and upload it 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,j=0,k=0,length_of_anode_terminal_array, anode_terminal_value=0,temp=0; int anode_terminal_array[]={63, 6, 91, 79, 102, 109, 125, 7, 127, 111, 0}; int cathode_terminal_array[]={254, 253, 251, 247, 239, 223, 191, 127}; 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(k=0;k<25;k++) // This loop provides a time delay to adjust the speed of display { for(j=0;j<8;j++) // This loop is for accessing the array elements { for(i=0;i<2;i++) // This loop will increase the brightness of LEDs { // 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[j]); // 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); } } /*** ROTATE THE 'anode_terminal_array' ONE POSITION TOWARDS LEFT SIDE *****/ // Get the length of "anode_terminal_array" length_of_anode_terminal_array = sizeof(anode_terminal_array)/sizeof(anode_terminal_array[0]); // Copy the first element of array to 'temp'. temp=anode_terminal_array[0]; /**** Shift all the elements of "anode_terminal_array", other than first element, one position towards left ****/ for(i=1;i<length_of_anode_terminal_array;i++) { anode_terminal_array[i-1]=anode_terminal_array[i]; } /**** Copy the value in 'temp' to last position of 'anode_terminal_array'. Then first element in old array becomes last element in new array ****/ anode_terminal_array[length_of_anode_terminal_array-1]=temp; }
If uploading is successful, scrolling numbers will be generated in the seven segment displays. Speed of scrolling can be adjusted by changing the upper limit of "k" loop. Brightness of LEDs can be adjusted by changing the upper limit of "i" loop.
Next : Video of Amazing Pattern in a Cluster of 8 Common Cathode Seven Segment Displays >>>> |
0 comments: