So I have been working on a "shield" (actually 3 layers of protoboard with wires everywhere, I don't have access to tools to make pcbs) that controls 2 8*8 RG led matrices using only 4 arduino pins, and two more optionally for the pins on the shift register for high-impedance mode and the register clear pin.
I have one matrix all wired up, and I have been testing it with various things.
Right now I have a little animated smiley face that opens and closes its mouth.
But the eyes, which should be a 4 dot square, only have the upper half showing.
I have checked and all the pixels in the matrix are functional, so I think this may just be a silly mistake in my code. Yet I cant figure it out!
Here's the code:
/*
Data is sent out in bytes, green-->red-->rows
*/
const int clockPin = 2;
const int dataPin = 3;
const int latch1 = 4;
const int latch2 = 5;
const int oePin = 6;
const int clrPin = 7;
byte rows[8] = {
B00000001,
B00000010,
B00000100,
B00001000,
B00010000,
B00100000,
B01000000,
B10000000
};
byte greenEyes[8] = {
B00000000,
B01100110,
B01100110,
B00000000,
B00000000,
B00000000,
B00000000,
B00000000
};
byte redMouth[8] = {
B00000000,
B00000000,
B00000000,
B00000000,
B10000001,
B11000011,
B01111110,
B00111100
};
byte redOpen[8] = {
B00000000,
B00000000,
B00000000,
B00000000,
B11111111,
B10000001,
B01000010,
B00111100
};
void setup() {
for(int i = 2; i<=7; i++) {
pinMode(i, OUTPUT);
}
}
void loop() {
long time=millis();
while(time > millis() - 500) {
for(int i =0; i<8; i++) {
digitalWrite(latch1, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, greenEyes[i]);
shiftOut(dataPin, clockPin, MSBFIRST, redMouth[i]);
shiftOut(dataPin, clockPin, LSBFIRST, rows[i]);
digitalWrite(latch1, HIGH);
}
}
time = millis();
while(time > millis() - 500) {
for(int i =0; i<8; i++) {
digitalWrite(latch1, LOW);
shiftOut(dataPin, clockPin, LSBFIRST, greenEyes[i]);
shiftOut(dataPin, clockPin, MSBFIRST, redOpen[i]);
shiftOut(dataPin, clockPin, LSBFIRST, rows[i]);
digitalWrite(latch1, HIGH);
}
}
}
Any help? Thanks
![]()