Control 4 digit 7 segments LED

Hi,

I have a 4 digit 7 segments LED (HS420561K-32).

Naively I thought chaining 74HC595 will be able to control this LED. I forgot of the fact where to connect the extra wires from the chained ICs.

The LED pins connected to the IC and works one digit at a time OK. Depend on which point I connect the negative (D1, D2, D3, D4).

I tried something which seems to be working but not sure if it is correct and do not want to destroy the Arduino board or anything.

So I connected the digital 10, and 12 to the D1, and D2.
In script I use digitalWrite(D1, LOW) to turn it off and digitalWrite(D1, HIGH) to turn it on.
If I use no delay I can display different characters on each digit at the same time.

Here is the part of the script

void loop() 
{
  
  delay(0);
  for(int j = 0; j < 2; j++) {
    leds = 0; // Initially turns all the LEDs off, by giving the variable 'leds' the value 0
    updateShiftRegister();
    for (int i = 0; i < 8; i++) // Turn all the LEDs ON one by one.
    {
      if(j%2 == 0) {
        digitalWrite(segment2, LOW);
        digitalWrite(segment1, HIGH);
        numberTwo(i);    // Set the bit that controls that LED in the variable 'leds'
      }
      if(j%2 == 1) {
        digitalWrite(segment2, HIGH);
        digitalWrite(segment1, LOW);
        numberOne(i);    // Set the bit that controls that LED in the variable 'leds'
      }
      
      updateShiftRegister();
      delay(0);
    }
    delay(0);
  }
}

void numberOne(int i) {
  if(i == 1 || i == 2) {
    bitSet(leds, i);
    }
  }

void numberTwo(int i) {
  if(i == 2 || i == 5 || i == 7) {return;}
  bitSet(leds, i);
}

Is it OK to do this way or it will cause problem?
It was running for 10 minutes without any problem. I have found no overheated component.

Regards

Laszlo

Ps.: Apologies if I am not using the correct words.

It is amazing what a good schematic will tell you and us, why not draw one,not a frizzy thing. Your 10 minute smoke test is not a very reliable test, of course if one part smokes then you know about that one. Your link works but there is no real technical data there other then it is a common cathode. What are the current limits on each segment and digit. What is your supply voltage? ..etc

Get yourself a MAX7219, make life a lot easier with simple command to update a display:

digitalWrite (ssPin, LOW);
SPI.transfer (registerAddress); // 1 to 4 for the 4 displays
SPI.transer (numberToDisplay); // 0 to 9, H E L P -
digitalWrite (ssPin, HIGH);

Need a 10uF cap, 0.1uF cap, 10K resistor.

Hi,
Have you googled.

arduino 7 seg displays 74HC595

This may help, note; it is an Instructable so may not be completely accurate.

Tom... :grinning: :+1: :coffee: :australia:

The TM1637 is another chip that's designed specifically for this kind of displays. You can get these 7-segment displays with TM1637 as backpack and a simple 4-wire interface for cheap (as in ~1 USD each). By far the easiest to incorporate such a display in your design. There's a TM1637 library for Arduino that makes control dead easy.

What you are describing is this. What you are doing is turning on one segment pin and one digit pin, then cycling thru all of them one at a time. Also known as Multiplexing.


Make sure you have a current limit resistor in series with the LEDs to prevent burning out the Arduino pins, or burning out the LEDs, in the event that the program should develop an error and stop with an output pair turned on and driving current into one LED for an extended time.

Note particularly the resistors in CrossRoads' diagram. These are needed to limit the current per Arduino pin. As shown, a 220 Ohm resistor will limit the "digit" current for the Arduino safely given that you only enable one digit at a time however the brightness will be limited by the number of segments lit at any one time.

This can be remedied by using resistors in the segment leads instead however the "digit" current may be excessive with all segments ("8") lit so the segment resistors should be 1k. Alternatively you can use transistors to switch the digit current and deliver the full 20 mA (150 Ohm resistors) to the segments.

And your program is responsible for performing the multiplexing. Somewhat tedious, requiring clever coding but if the processor has not too much to do overall, a cheap option and used in simple commercial applications. If however your processor has many other things to do or you want many displays, you really need to use the dedicated display driver chips such as the MAX7219 which once given the appropriate data, perform all the multiplexing and full current driving for you.

Complete assembled 8 digit displays with MAX7219 are cheaply available on Aliexpress.

1 Like

Yes, I have current limiter resistor(220 Ohm). The only difference is that those resistors on the segment pins rather then on the digit pin.

Thank you for the help to everyone.
I decided to go with the MAX7219 IC and I found something good product on Amazon.

It must be the same or very similar to what @Paul_B recommended.

Thank you again to be so helpful.

I am going to purchase Fritzing today and hopefully I will be able to draw the schematic and share here later.

Indeed it is, exactly the one. Aliexpress is much cheaper, but you may have forgotten why you wanted it by the time it is delivered. :roll_eyes:

Please don’t do that on our account, by and large this package is hated by most people on the forum because beginners use it to create a physical layout diagram not a schematic. True it can be used as a schematic drawing tool but it is not very easy to produce a passable schematic.

You are better off using a pen an paper and photographing the results.

Yes, you are right.
That's the reason I choose a more expensive one.

I went against your advice. And not because I want to ignore you. And not because I am the know everything guy.
The reason is I want to create PCBs at some point for further projects and I like to explore things. This tool looks pretty good to me and seems to do everything I might need later.
And yes, paper and pencil would take only 10 minutes to draw while it took a bit more than 1 hour to create in Fritzing.

Here is the drawing. I hope it is not too bad.

Wrong value for resistors.

As I explained in #7, the segment resistors should be 1k.

You are right.
I have updated the drawing.

I have seen worse but what are all those unnecessary crossings about? And the labelling is poor.

The tool might seem good for you only because you know so little about tools and what you can do with them. There are many much better ones for free.

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