Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <ShiftRegister74HC595.h>
- //My display matrix connection image: https://imgur.com/a/v81w42t
- //Please change this two value with total Shift Register no in row and column.
- const int rowRegNo=1;
- const int columnRegNo=2;
- //In my Matrix Display
- //DataPin = Blue cable
- //LatchPin = Green cable
- //ClockPin = White cable
- int v5=2;
- int dpC=2,lpC=3,cpC=4;//Pins of Column
- int dpR=5,lpR=6,cpR=7;//Pins of Row
- const int rowSize=rowRegNo*8;
- const int columnSize=columnRegNo*8;
- ShiftRegister74HC595<rowRegNo> rReg(dpR,cpR,lpR);
- ShiftRegister74HC595<columnRegNo> cReg(dpC,cpC,lpC);
- int* alphaMt;
- bool mt[rowSize][columnSize] = {
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
- {0,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0},
- {0,1,0,0,1,0,1,0,0,0,0,0,0,0,1,0},
- {0,1,0,0,1,0,0,0,1,1,1,1,0,1,1,0},
- {0,1,1,1,1,0,1,0,0,0,1,0,0,0,1,0},
- {0,1,0,1,0,0,1,0,0,1,0,0,0,0,1,0},
- {0,1,0,0,1,0,1,0,1,1,1,1,0,1,1,1},
- {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}
- };
- uint8_t mtB[][2]={{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
- void setup() {
- Serial.begin(9600);
- pinMode(v5, OUTPUT);
- setupBoolDisp();
- initAlpha();
- }
- void loop(){
- showDisplay();
- }
- int pos=15,tm=0;
- void showDisplay() {
- tm++;
- if (!(tm%20)) {
- pos--;
- if(pos<0) pos=15;
- }
- rReg.setAllHigh();//Reverse
- cReg.setAllLow();//Reverse
- for (int r=0; r<rowSize; r++){
- rReg.set(r, LOW);
- for (int c=0; c<columnSize; c++){
- int x=(c+pos)%16;
- if (mt[r][c])
- cReg.setNoUpdate(x,HIGH);//p2
- //cReg.set(x, HIGH);//p1
- }
- cReg.updateRegisters();//p2
- delay(1);
- //cReg.setAll(mtB[r]);
- delay(1);
- cReg.setAllLow();//Reverse
- rReg.set(r, HIGH);//Reverse
- }
- }
- void setupBoolDisp(){
- for (int i=0; i<8;i++){
- int y=0;
- for (int j=0; j<16; j++){
- int idx=j/8 , p=j%8;
- mtB[i][idx]|=(1<<p) *mt[i][j];
- }
- // Serial.print(mtB[i][0]);
- // Serial.print(",");
- // Serial.println(mtB[i][1]);
- }
- }
- void initAlpha(){
- int x[rowSize][columnSize]={{0,9}};
- //alphaMt = x;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement