I'm currently driving a common-cathode 4 digit display using a 74595. Unfortunately, since this chip can't source enough current for driving all the LEDs, I will have to get a common-anode model however right now I am using 7 transistors to provide enough current.
For a test, I'm only lighting one digit at a time. Using the numerous tutorials I've found around the web, my code looks like this:
//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;
int i;
byte digitOne[10] = {0x3F, 0x6, 0x5B, 0x4F, 0x66, 0x6D, 0x7D, 0x7, 0x7F, 0x6F};
void setup()
{
//set pins to output so you can control the shift register
pinMode(latchPin, OUTPUT);
pinMode(clockPin, OUTPUT);
pinMode(dataPin, OUTPUT);
}
void loop()
{
for(int i=0; i<10; i++)
{
digitalWrite(latchPin, LOW);
shiftOut(dataPin, clockPin, MSBFIRST, digitOne[i]);
digitalWrite(latchPin, HIGH);
delay(500);
}
}
With LED A connected to output A and so on. The problem is, every so often LED G (the middle one) will go out. The 2 and 3 will look weird, and yet the 5 and 6 work perfectly fine.
I've encoded the numbers so that LED A represents bit 2^0, LED B is bit 2^1, and so on. For example, 7 would be 2^0 + 2^1 +2^2, or 7 (which is still 0x7 in hex). Could it be an issue with that? I've swapped that digit's wires so it's not a physical issue.
Edit: Now more LEDs are doing it. Here's a GIF example: