Cascading Shift Registers

Hello -

Just got started with development on my Photon and I’ve been attempting to use two SN74HC595N shift registers to drive a two digit (common anode) 7 segment display. Ive written up a basic file to cycle though digits 0-9 and it appears to work correctly when using one shift register for one digit of the display:

void WriteZero() {
    digitalWrite(latchPin, LOW);
    // Turn off G and DP
    shiftOut(dataPin, clockPin, LSBFIRST, 0b00000011);
    digitalWrite(latchPin, HIGH);
}

However when I cascade a second shift register and duplicate the shiftOut call:

void WriteZero() {
    digitalWrite(latchPin, LOW);
    // Turn off G and DP
    shiftOut(dataPin, clockPin, LSBFIRST, 0b00000011);
    shiftOut(dataPin, clockPin, LSBFIRST, 0b00000011);
    digitalWrite(latchPin, HIGH);
}

My display does not correctly show ’ 00 '. I’ve been able to get around this by writing a “Clear()” function and using that in between writing each number:

void Clear() {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, LSBFIRST, 0b11111111);
    shiftOut(dataPin, clockPin, LSBFIRST, 0b11111111);
    digitalWrite(latchPin, HIGH);
}

Every article I have seen online does not have to do this. Some of the numbers appear correctly without the Clear() call - I believe ‘66’, ‘77’, and ‘88’. I know manually clearing the register each time is inefficient and am trying to figure out what I am missing here.

Any help is appreciated - thanks.

Use the code in your first example but connect both displays, and cycle through the digits. If wired correctly, the 2nd digit should trail by one digit, e.g. counting digits you’d see " 0", “01”, “12”, “23”, “34”, etc.

Does that work? If so then the problem is in your software. Does that fail? If so the problem is in your hardware.

OK, so I ended up shifting my code and attempting this and it returned some really weird results. I checked my connections and ended up removing the 100Ohm resistor powering the display and it worked itself out.