KRITSADA

74595 Shift Register Matrix display

Feb 16th, 2022
2,222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <ShiftRegister74HC595.h>
  2.  
  3. //Please change this two value with total Shift Register no in row and column.
  4. const int rowRegNo=1;
  5. const int columnRegNo=2;
  6.  
  7. //In my Matrix Display
  8. //DataPin  = Blue cable
  9. //LatchPin = Green cable
  10. //ClockPin = White cable
  11. int dpR=2,lpR=3,cpR=4;//Pins of Row
  12. int dpC=5,lpC=6,cpC=7;//Pins of Column
  13.  
  14. const int rowSize=rowRegNo*8;
  15. const int columnSize=columnRegNo*8;
  16. ShiftRegister74HC595<rowRegNo> rReg(dpR,cpR,lpR);
  17. ShiftRegister74HC595<columnRegNo> cReg(dpC,cpC,lpC);
  18.  
  19. int* alphaMt;
  20.  
  21. bool mt[rowSize][columnSize] = {
  22.   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
  23.   {0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0},
  24.   {0,1,0,0,1,0,1,0,0,0,0,0,0,0,1,0},
  25.   {0,1,0,0,1,0,0,0,1,1,1,1,0,1,1,0},
  26.   {0,1,1,1,1,0,1,0,0,0,1,0,0,0,1,0},
  27.   {0,1,0,1,0,0,1,0,0,1,0,0,0,0,1,0},
  28.   {0,1,0,0,1,0,1,0,1,1,1,1,0,1,1,1},
  29.   {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
  30. };
  31.  
  32. void setup() {
  33.   initAlpha();
  34. }
  35.  
  36. void loop(){
  37.   showDisplay();
  38. }
  39.  
  40. int pos=15,tm=0;
  41. void showDisplay() {
  42.   tm++;
  43.   if (!(tm%20)) {
  44.     pos--;
  45.     if(pos<0) pos=15;
  46.   }
  47.  
  48.   rReg.setAllHigh();//Reverse
  49.   cReg.setAllLow();//Reverse
  50.  
  51.   for (int r=0; r<rowSize; r++){
  52.     rReg.set(r, LOW);
  53.     for (int c=0; c<columnSize; c++){
  54.       int x=(c+pos)%16;
  55.       if (mt[r][c]) cReg.set(x, HIGH);
  56.     }
  57.     cReg.setAllLow();//Reverse
  58.     rReg.set(r, HIGH);//Reverse
  59.   }
  60. }
  61.  
  62. void initAlpha(){
  63.   int x[rowSize][columnSize]={{0,9}};
  64.   //alphaMt = x;
  65. }
  66.  
Advertisement
Add Comment
Please, Sign In to add comment