<<<< Read previous part (Part 4)
We had already seen the theory behind the operation of 16*8 LED matrix in previous blogs. Our next aim is to create those frames and display each, one after another, at a high speed. Complete the circuit given in this page. Upload the following program to your arduino board. This program will create the first frame we found in last blog.
Output of the above program can be seen in 16*8 LED display. Output is given below.
Arduino will shift out number 254 to the first 74595. Then, 254 will be stored in first 74595. After that, arduino will shift out number 195 to the first 74595. Then, 254 will be shifted to the second 74595 from first 74595 and 195 will be stored in first 74595. After that, arduino will shift out 254 to the third 74595. This can be pictorially represented as shown below. 195 stored in first 74595 will appear across the anode terminals of first 8*8 LED matrix. 254 stored in second 74595 will appear across the anode terminals of second 8*8 LED matrix. 254 stored in third 74595 will appear across the cathode terminals of both 8*8 LED matrices which will give the expected output.
int latchPin = 11; //Pin connected to ST_CP of 1st 74595 int clockPin = 12; //Pin connected to SH_CP of 1st 74595 int dataPin = 13; //Pin connected to DS of 1st 74595 int latchPin2 = 8; //Pin connected to ST_CP of 2nd 74595 int clockPin2 = 9; //Pin connected to SH_CP of 2nd 74595 int dataPin2 = 10; //Pin connected to DS of 2nd 74595 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() { // take the latchPin low so the LEDs don't change while you're sending in bits: digitalWrite(latchPin, LOW); //Send 1 1 1 1 1 1 1 0 (254) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 2nd 74595 shiftOut(dataPin, clockPin, MSBFIRST, 254); //Send 1 1 0 0 0 0 1 1 (195) to Q7 Q6 Q5 Q4 Q3 Q2 Q1 Q0 of 1st 74595 shiftOut(dataPin, clockPin, MSBFIRST, 195); // 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 3rd 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 3rd 74595 shiftOut(dataPin2, clockPin2, MSBFIRST, 255); // shift out the bits: digitalWrite(latchPin2, HIGH); }
Output of the above program can be seen in 16*8 LED display. Output is given below.
Arduino will shift out number 254 to the first 74595. Then, 254 will be stored in first 74595. After that, arduino will shift out number 195 to the first 74595. Then, 254 will be shifted to the second 74595 from first 74595 and 195 will be stored in first 74595. After that, arduino will shift out 254 to the third 74595. This can be pictorially represented as shown below. 195 stored in first 74595 will appear across the anode terminals of first 8*8 LED matrix. 254 stored in second 74595 will appear across the anode terminals of second 8*8 LED matrix. 254 stored in third 74595 will appear across the cathode terminals of both 8*8 LED matrices which will give the expected output.
Continued in Next Part (Part 6) >>>> |
0 comments: