So what I am currently working on is the ever popular LMP. I am using a common anode rgb matrix. I am also using four 74hc595 shift registers which are all chained together. What I am trying to do is come up with a few different functions. The first one is to turn on a complete row and be able to stipulate a certain color. The problem I am running into is with green. I can use the function to address each row separately but when I try and use a for loop it skips every other row. I have printed the number that the for loop is feeding in and it seems just fine. But somehow when it gets to the shift register it just sucks. I can address seperatley but not in for loop. Any help would be great. Here is the code.
//Pin connected to ST_CP of 74HC595
int latchPin = 8;
//Pin connected to SH_CP of 74HC595
int clockPin = 12;
////Pin connected to DS of 74HC595
int dataPin = 11;
void setup() {
Serial.begin(9600);
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void all_row(int row, char color)
{
int row_table[8]={1,2,4,8,16,32,64,128};
if(color=='r')
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, row_table[row]);
shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
digitalWrite(latchPin, HIGH);
}
if(color=='g')
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, row_table[row]);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
digitalWrite(latchPin, HIGH);
}
if(color=='b')
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, row_table[row]);
shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
shiftOut(dataPin, clockPin, MSBFIRST, 0);
shiftOut(dataPin, clockPin, MSBFIRST, 0xff);
digitalWrite(latchPin, HIGH);
}
}
void loop()
{
for(int j=0;j<8;j++)
{
Serial.println(j);
all_row(j,'g');
delay(1000);
}
}