Help with Elegoo 4 Digit 7 Segment Display Tutorial

Hello All,

I cannot figure this out. I have my Uno configured exactly as the view below, however, the 4 digits do not cycle through as the tutorial shows (1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, f). Instead it goes 1, 3, 5, 7, then gets jumbled, and repeats.

Oddly enough, if I move the red jumper wire from the 5v Pin on the Uno board to the Vin pin on the Uno board, it works perfectly. This makes no sense to me, and I cannot figure why that would solve the problem.

Any guidance? Code is below:

//www.elegoo.com
//2016.12.12

int latch=9;  //74HC595  pin 9 STCP
int clock=10; //74HC595  pin 10 SHCP
int data=8;   //74HC595  pin 8 DS

unsigned char table[]=
{0x3f,0x06,0x5b,0x4f,0x66,0x6d,0x7d,0x07,0x7f,0x6f,0x77,0x7c
,0x39,0x5e,0x79,0x71,0x00};

void setup() {
  pinMode(latch,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(data,OUTPUT);
}
void Display(unsigned char num)
{

  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,table[num]);
  digitalWrite(latch,HIGH);
  
}
void loop() {
  Display(1);
  delay(500);
  Display(2);
  delay(500);
  Display(3);
  delay(500);
  Display(4);
  delay(500);
  Display(5);
  delay(500);
  Display(6);
  delay(500);
  Display(7);
  delay(500);
  Display(8);
  delay(500);
  Display(9);
  delay(500);
  Display(10);
  delay(500);
  Display(11);
  delay(500);
  Display(12);
  delay(500);
  Display(13);
  delay(500);
  Display(14);
  delay(500);
  Display(15);
  delay(500);
}

Presumably you are powering this via the USB port.

Put a 0.1 µF (or somewhat more) ceramic directly across the supply to the 74HC595. Connect pin 10 to 5 V.

You are correct in assuming it is powered by USB. Apologies for not calling that out.

I will give the capacitor a try. For my knowledge though (I’m not an EE), what does the capacitor accomplish? Why would the board work with the red jumper on Vin instead? Can you help me understand the logic behind placing the capacitor for my knowledge?

Still very new at this.

Thanks!

It is odd that you are having trouble with this because the two detailed tutorials on Youtube do not show the need of a capacitor.

Are you sure you have everything connected correctly?

Vin is one diode drop from the barrel connector which is not connected since you are using your PC's USB.

Attached is a picture of my setup.

It seems odd that it even works without the 5v pin wired up.

I also checked and rechecked the code as well. The pins are called out correctly.

I also tried a separate power board. Same behavior.

I may try to take a video to show behavior if anyone may find that helpful.

Definitely add that 0.1uF cap, and leave it there, even if it does not fix your problem. Internet tutorials may not show it, but the '595 manufacturer's data sheet will, and they know best.

Speaking of bad tutorials, shame on Elegoo. This circuit will draw 60mA from each '595 output pin, and the limit is 35mA. With all 8 segments lit, that's 480mA in total, when the limit is 70mA for the '595, and 500mA for USB, which needs to power the Arduino at the same time.

Thanks for the help. Would I put the capacitor on pins 8 and 16? Google tells me it should be between Vcc and Ground. However above it is stated to put it between Vcc and pin 10 (which is master reset) if I'm assuming correctly he meant pin 10 of the 595.

No, I said Put a 0.1 µF (or somewhat more) ceramic directly across the supply to the 74HC595. The supply is pins 16 and 8.

Connect pin 10 to 5 V (pin 16). because your diagram showed it was not connected. :astonished:

Paul__B:
No, I said Put a 0.1 µF (or somewhat more) ceramic directly across the supply to the 74HC595. The supply is pins 16 and 8.

Connect pin 10 to 5 V (pin 16). because your diagram showed it was not connected. :astonished:

I've never seen a 7 Segment tutorial that has pin 10 connected on the 74HC595 - can you help me understand what purpose it serves?
I apologize for not knowing any better. Unfortunately crawling comes before walking, and I'm still trying to roll over. :confused:

obsessed:
I've never seen a 7 Segment tutorial that has pin 10 connected on the 74HC595 - can you help me understand what purpose it serves?

It is the reset line for the shift register. If you pull it low it zeroes the register. If you hold it low, you can do nothing with the 74HC595. If you let it float it is likely to randomly zero the register.

If you ever see a tutorial which shows it not connected, you know the author is totally clueless, it is advisable to keep well away from such a website. As PaulRB points out, the circuit you illustrate is an excellent example. :roll_eyes:

Some research indicates this was discussed a few years back, no doubt more than once. :grinning:

Thanks everyone for your help!

The issue was the missing connection to pin 10, as suspected. I made that connection and it works flawless.

Thanks so much for your patience with a newbie. I just bought a kit with different things to try to learn, as I want to incorporate an Arduino (Nano maybe?) into a specific project I have in mind, but I have a lot to learn before I can make that happen. :slight_smile:

I have capacitors on order, and will use one as suggested as well.

This tutorial doesn’t reflect well on Elegoo. You have all four digits displaying the same character instead of being individually controlled by the Arduino. And the current drawn by all the segments of a digit flows through a single resistor, which means the segments of an “8” will be dimmer than the segments of a “1”. And where in the code is the display of “0”?

ShermanP:
This tutorial doesn't reflect well on Elegoo.

Not to mention pin ten! :roll_eyes:

Given all the other connections are - sort of - workable and the code straightforward, the behaviour cited by the OP is extremely hard to explain and I spent some considerable time examining the code for some obscure error.

So having the shift register erratically and sort of randomly cleared really is about the only explanation (and even then does not properly explain "instead it goes 1, 3, 5, 7, " unless it was actually blanking in between). Unfortunately we frequently have to work on a not-quite-accurate description of the problem. :sunglasses:

But do keep (using) the 0.1 µF capacitor(s). :grinning: