Skip to main content
2 of 2
added 88 characters in body
Esshahn
  • 217
  • 1
  • 3
  • 11

Can't get 4 digit 7 segment display to show different values

I'm an Arduino newbie having problems getting a 4 digit 7 segment display to work. The display is connected to a 74HC595 and the setup is from the elegoo tutorial 28 (I think it is download only).

I figured how to control which number to display, but all 4 digits always share the same number, so it is always like 1111, 5555, 9999 etc.

I've heard about something called multiplexing which might do the trick, but I can't adapt it to my project yet, missing too much experience.

This is the code that toggles between 2222 and 8888. I want to be able to display any number like 1234 though.

Any help is very appreciated.

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

void setup()
{
  pinMode(latch,OUTPUT);
  pinMode(clock,OUTPUT);
  pinMode(data,OUTPUT);
}

void Display(unsigned int num)
{  
  digitalWrite(latch,LOW);
  shiftOut(data,clock,MSBFIRST,num);
  digitalWrite(latch,HIGH); 
}

void loop()
{
    Display(91);
    delay(1000);
    Display(127);
    delay(1000);
}

image taken from the tutorial

Esshahn
  • 217
  • 1
  • 3
  • 11