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.