Single digit 7 segment display using shift register

Trying to use the 74HC595 shift register to control a 7-segment display. Only getting the number 8 out of my display and i dont know why. Added a picture of my tinkercad circut and my code below.

int INPin = 4;
int OTPin = 3;
int SFTPin =2;

int digit [10] {1,79,18,6,76,36,32,15,0,4};

void setup () {
pinMode(INPin, OUTPUT);
pinMode(OTPin, OUTPUT);
pinMode(SFTPin, OUTPUT);

void loop () {
for (int i=0;i<10;i++) {
digitalWrite(OTPin, LOW);
shiftOut(INPin, OTPin, LSBFIRST, digit*);*

It would help if you posted a schematic rather then the frizzy thing. It appears you do not have it wired properly. With the schematic you do not have to constantly count pins and read the data sheet, the pins would be labeled. Example pin 10.

Please read this:-
How to get the best out of this forum
Because your post is breaking the rules about posting code.

I don't think you understand the shift out

shiftOut(INPin, OTPin, LSBFIRST, digit);

the variable digit is supposed to be a byte char or int type. You have attempted to use an array, and done that wrong anyway.
It might be that you meant to write

shiftOut(INPin, OTPin, LSBFIRST, digit[i]);

Maybe that is what you wrote?
But because you have not used code tags, the forum software has interpreted the i in square brackets as an instruction to switch into italics. That is why code tags are important.

int digit [10] {1,79,18,6,76,36,32,15,0,4};

Should be this if you want an array

int digit [] = {1,79,18,6,76,36,32,15,0,4};

And what are those numbers supposed to mean? They don't make any sense. They are not 7 segment patterns are they?

When posting code please say what it does ( you have done this by saying it displays 8 ) but you also need to say what you hoped it would do. This is not clear from your code because of the errors you have made.

P.S. A black wire over a black background ( the chip ) is not the easiest thing to follow.

There is no need to connect both cathode pins of the display; one will suffice, and you have not connected the decimal!

The wiring indicates that you are using a common cathode 7 segment display, where you bring a segment HIGH to turn it on.
The array, however, {1,79,18,6,76,36,32,15,0,4} appears to be designed for a common anode display because bringing a segment HIGH turns the segment off.
You’ve defined a pin SFTPin (the 595 clock pin) but don’t use it in the shiftOut() function.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.