how to control a 8x32 dot matrix with 74hc595 shift Regsters

hello

so i've started using arduino and shift registers. with the lack of knowledge and the bit of c programing that i know (not that much) , and also through a lot of research , i was able to control an 8x8 dot matrix with 2 74hc595 chips which were not daisy chained (all though a was not able to control it like i wanted du to the lack of knowledge).
now i made a bigger matrix, a 8x32 and already wired up all the shift register. 4 of them are daisy chained to get 32 outputs for the 32 colums and 1 is used for the 8 rows.

here is the problem now .

to try if the matrix was functioning properly i just upoaded the code of a smily face of the 8x8 matrix to the 8x32 matrix and 4 smily faces show up .

now i wanted t do something else with the matrix , i know how to send 8 bits but not 32 :confused: :confused:.

i'm having troube adapting the code to the 8x32 matrix . all my for loops are from 0 to 8 and i thought that changing the inner loop to 32 wold work buuuut it didn't

they way my matrix is wired only allows one row to be lit a time .

and i know the max7219 exists and its a lot easier ( i actualy bought one 8x32 controled with the max7219) people say that should use that one instead, but i just want to know how it works with these 74hc595

//Columns
int clockpin1 = 2; 
int latchpin1 = 3; 
int datapin1 = 4;  

//Rows
int clockpin2 = 5; 
int latchpin2 = 6; 
int datapin2 = 7; 

void setup() {
 pinMode(latchpin1, OUTPUT);
 pinMode(clockpin1, OUTPUT);
 pinMode(datapin1, OUTPUT);

 pinMode(latchpin2, OUTPUT);
 pinMode(clockpin2, OUTPUT);
 pinMode(datapin2, OUTPUT);
}

int pic[] = {0, 0, 102, 102, 0, 0, 66, 60};
void loop()
{
  for (int i=0 ; i<8 ; i++)
  {
  digitalWrite(latchpin2, LOW);
  shiftOut(datapin2, clockpin2,MSBFIRST,128>>i);
  digitalWrite(latchpin1, LOW);
  for (int j=0 ; j<8 ; j++)
  { 
  shiftOut(datapin1, clockpin1,MSBFIRST,pic[i]);
  
  } 
  digitalWrite(latchpin1, HIGH);
  digitalWrite(latchpin2, HIGH); 
}
}

Looks like these are the areas to expand:

Data

int pic[] = {0, 0, 102, 102, 0, 0, 66, 60};

Datashifted out

 digitalWrite(latchpin1, LOW);
 for (int j=0 ; j<8 ; j++)
 { 
 shiftOut(datapin1, clockpin1,MSBFIRST,pic[i]);
 
 } 
 digitalWrite(latchpin1, HIGH);

So let's say i wanted to display a rectangle that is 8x32 in size how would I send data for that ?
Since there are 4 shift registers for the 32 colums
The first led of each colums would be on them for rows 2 to 7 there would be one led from the first and the last colums on, then all the leds of the of the last row would be on.

11111......11111111
10000......00000001
10000......00000001
10000......00000001
10000......00000001
10000......00000001
10000......00000001
11111......11111111

So how can I send 32bits of data to the 4 shifregisters everytime I switch rows

And also what kind of numbers am I going to use ?

I know that 129 in decimal == 10000001 binary but that's only 8 bits

I would like to have 1000000000000000000000000000000001 which is too big in decimal and I often get errors 8n the ide.

You can set the patterns in binary:

byte pic [8][4] = {
  {0b11111111, 0b11111111, 0b11111111, 0b11111111},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b11111111, 0b11111111, 0b11111111, 0b11111111}
};

this the loop that sends data to the shift registers

void loop()
{
  for (int i=0 ; i<8 ; i++)
  {
  digitalWrite(latchpin2, LOW);
  shiftOut(datapin2, clockpin2,MSBFIRST,128>>i);
  digitalWrite(latchpin1, LOW);
  for (int j=0 ; j<8 ; j++)
  { 
  shiftOut(datapin1, clockpin1,MSBFIRST,pic[i]);
  
  } 
  digitalWrite(latchpin1, HIGH);
  digitalWrite(latchpin2, HIGH); 
}
}

the outer loop just counts from 0 to 7 for the 8 rows that have to be lit

but im having trouble ajusting this part for everything to work properly :

for (int j=0 ; j<8 ; j++)
  { 
  shiftOut(datapin1, clockpin1,MSBFIRST,pic[i]);
  
  }

and it does not work when i try to send this :

byte pic [8][4] = {
  {0b11111111, 0b11111111, 0b11111111, 0b11111111},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b10000000, 0b00000000, 0b00000000, 0b00000001},
  {0b11111111, 0b11111111, 0b11111111, 0b11111111}
};

how do i even select what's supposed to be sent , just using pic* wiht i from 0 to 7 is not working .*
i dont know?
am i suppesed to creat an other loop for the 4 binary numbers that are going to be sent for each of the 8 rows ?
when its just int pic[] = {0, 102, 102, 0, 0, 0, 66, 60};
*the loop with i=0 to 7 works , as it send the numners one by onne *
and the 128>>i lits the row one by one
* *            10000000   00000000     0                    01000000   01100110     102             00100000   01100110     102  128>>i     00010000   00000000     0             00001000   00000000     0         {0, 102, 102, 0, 0, 0, 66, 60};             00000100   00000000     0             00000010   01000010     66             00000001   01111110     60* *
as a result i get a smiley face ( that' waht's in the middle)
i also tried leaving pic as is and modify 128>>i to 0b10000000>>i
that didn't work either.
*i think i my main problem is sending a specific type of data, if i could get some explanation of how it works it would be great *

for (int j=0 ; j<4 ; j++)
  { 
    shiftOut(datapin1, clockpin1,MSBFIRST,pic[i][j]);
  }

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.