Strange Issue with 10 Digitx7 Segment LED Strip Using 74HC595 and ULN2003AN

Hi All,
This is my first post on this forum and I would really appreciate any guidance on an issue I’m having. I am building a cricket scoreboard using an Arduino Uno with each individual digit made up of 7 led segments. The digits will be controlled using 9 74hc595 shift registers that go through a uln2003an. The Arduino Uno and the uln2003an are fed by 8-AA batteries (12V), and the shift registers get 5V from the Uno. A sketch is attached showing the circuit setup and connections (due to size limitations only the start of the circuit is shown and the rest of the shift registers are replicated in the same pattern). The only thing missing from that is the LED segments that would be attached to the output of the UL2003AN on one end and to 12V on the other, and an itead bt shield that I will eventually use for interfacing. The LED segments are rated for 12V.

As part of the testing process, I have gone through and tested that I can individually control each and every segment of each digit without any issues. My problem starts when instead of directly turning segments on and off, I let the Arduino Uno figure out what pins to turn based on the digit to be displayed. The attached sketch starts off by defining a number for each of the 10 digits and I am calling a function which uses a switch statement to determine the digit and the pins to turn on (the pin status is stored in an integer array). The digit 0 through 6 work fine, and everything works as expected. When I define all the digits to be equal to 7, only one digit shows a 7, and the rest show 1. A picture of that result is also shown. I can also get all the digits to print an 8 but a similar issue arises when I assign all digits to be equal to 9 (only one digits prints a 9 and the others print a 4). I’m having a hard time seeing where the issue could be.

What’s interesting is that the segment that does not turn on in both instances for the digits is the one at the very top. Any help would be appreciated.

Daisy_Chain_Shift_Register_Code.ino (7.1 KB)

Wow, that is complicated way to send out 10 bytes to 10 shift registers.

I would have done this:

#include <SPI.h>
byte fontArray[] = {
0b00111111, // 0  DP-g-f-e-d-c-b-a,
0b00000110, // 1
0b01011011, // 2
//etc
0b01101111, // 9
0b00000000, // blank
};
byte digitArray[] = {0,1,2,3,4,5,6,7,8,9,}; // some data to start
byte latchPin = 10;
byte x;
byte updateFlag = 0;
void setup(){
pinMode (latchPin, OUTPUT);
SPI.begin();

digitalWrite (latchPin, LOW);
for (x=0; x<10; x=x+1){
SPI.transfer (fontArray[digitArray[x]]);
}
digitalWrite (latchPin, HIGH); // digits update on this rising edge
}
void loop(){
// add stuff to read score buttons, etc, and update digitArray, then
// set the updateFlag to 1

if (updateFlag == 1){ // something needs updating
updateFlag = 0;
digitalWrite (latchPin, LOW);
for (x=0; x<10; x=x+1){
SPI.transfer (fontArray[digitArray[x]]);
}
digitalWrite (latchPin, HIGH); // digits update on this rising edge
}
} // end loop

Could you not obtain TPIC6C595s?

Paul__B:
Could you not obtain TPIC6C595s?

I could, I’m not familiar with that chip, what would the benefit of using that be?

CrossRoads:
Wow, that is complicated way to send out 10 bytes to 10 shift registers.

I would have done this:

#include <SPI.h>

byte fontArray = {
0b00111111, // 0  DP-g-f-e-d-c-b-a,
0b00000110, // 1
0b01011011, // 2
//etc
0b01101111, // 9
0b00000000, // blank
};
byte digitArray = {0,1,2,3,4,5,6,7,8,9,}; // some data to start
byte latchPin = 10;
byte x;
byte updateFlag = 0;
void setup(){
pinMode (latchPin, OUTPUT);
SPI.begin();

digitalWrite (latchPin, LOW);
for (x=0; x<10; x=x+1){
SPI.transfer (fontArray[digitArray]);
}
digitalWrite (latchPin, HIGH); // digits update on this rising edge
}
void loop(){
// add stuff to read score buttons, etc, and update digitArray, then
// set the updateFlag to 1

if (updateFlag == 1){ // something needs updating
updateFlag = 0;
digitalWrite (latchPin, LOW);
for (x=0; x<10; x=x+1){
SPI.transfer (fontArray[digitArray]);
}
digitalWrite (latchPin, HIGH); // digits update on this rising edge
}
} // end loop

I’ll try this and see if the error is still there, thanks for the suggestion.

only4zubair: I could, I'm not familiar with that chip, what would the benefit of using that be?

It is a vastly superior functional equivalent of a 74HC595 and ULN200*8* in a single chip.

Go research it.