Usage of (and Determining Resistors for) LED 4-digit 7-segment Display?

I have done a couple projects where I used this four-digit, seven-segment LED to display a timer value: (data sheet:

Those projects were just tests. Now I'm doing a project that I'm actually going to print PCB's and create enclosures for and make several of them as gifts for people (it's a chess clock with two timers). So I want to make sure I'm doing it right. I suspect I'm not. :) I have the project breadboarded right now. What I'm doing is this: Hook up two 74HC595N shift registers to +5V and GND, and three digital pins on the Arduino. I connect one register's QH* to the next registers serial input. Then in the Arduino I shift out 16 bits to set the shift registers pins. I have twelve of the shift register pins hooked directly to the 12 pins on the LED. Since I can only drive one digit at a time, I iterate through them quickly - leaving each digit on for only a split second, then displaying the next digit, etc. So, for instance, since I have a common anode LED, I'll turn the pin for the first digit high, then the pins for each of the segments of that digit that I want to display low (with the other segments high).

Okay, I have some questions:

  • One: cycling through the digits rapidly leaving each on for only a split second: that's the only way I see to drive a display like this. Is that the correct way?
  • I don't have any resistors hooked up to the LEDs. With a typical LED, I have to hook up a resistor. Do I need a resistor on this thing?
  • If I do need a resistor, do I need one for each anode?
  • Also, how do I calculate the resistor to use for this display?
  • Any other tips?

The display is already pretty dim - I'm not sure if it's just a dim display, if I'm not driving it correctly, or that's just a function of the digits all being at approximately 25% duty cycle since I'm iterating through them many times per second. I adjust the length of time that each digit stays on a little bit. Too long and you see each digit fade away. Too short and it's blinking at you. There's a definite balance where each digit appears to the eye to be "constant".


“I have twelve of the shift register pins hooked directly to the 12 pins on the LED.”
12? Like 8 segments, and 4 cathodes?
74HC595 is only good for 6-8mA, with each digit on <25% of the time is not much average current to light up the LEDs.
Try a part that can sink more current so the average current is higher.
Many LEDs can be driven with higher currents, like 50mA - but only for 10mS every 100mS or something, need to read its spec.

That sounds over-complicated to me. If you can spare 9 pins (or 10 if you want to drive the decimal points as well), you can dispense with the 74HC595s. Use 7 or 8 pins to drive the segments of all 4 displays, with a single current limiting resistor on each Arduino pin to limit the current to 20mA or so. Then use a 2- to 4-line decoder (e.g. 74HC138) to decode the other 2 pins to 1 of 4 common digit lines, and use transistors to drive the common anodes or common cathodes of the displays from those 4 lines. If you can spare another 2 pins, you can dispense with the decoder as well.

If you need more than 20mA per segment to get enough brightness, use transistors or darlington arrays to buffer the 7 segment outputs too.


I want to be able to drive several four-digit seven-segment displays with the same Arduino, and with the other buttons, etc, that I have for this project, I can't use that many digital pins.


Thanks for the tips. I guess I just had the 7HC495 laying around when I did my first one, it worked (albeit not very brightly) and I never thought to look for "the right way" until now.

For those who later find this post, I'll post back what I find. For now I have found this: which shows using an LED driver (specifically Max7219/7221) to drive them. This looks good, but the chips are $8-$10 each (or more - way more than the price of the 328 I'm using for the Arduino), so I'm going to look for a lower-cost LED driver. If anyone has any suggestions, I'd be glad to hear them.

Also, here's a post where a guy used those drivers:

I have used the MAX7221 also, is a great chip. Instead of 74HC595, you can find shift registers that can sink more current. I bought a tube of 74AC299PC when they were on sale & I use those, they can do 24mA. Another option is 74LS595, good for 24mA also. Also 74LV595, good for 16mA.

So its a tradeoff - high speed SPI access direct to a register for the digit that changes with all digit decoding done in MAX7221, or the software doing the digit decoding and shifting out 4 digits every time (can also be done with SPI) with a lot more wiring needed.

Take a look at the STLED316S - under $2.50 last I checked. It's a constant current LED driver (40mA) that can handle a 4 digit 7-seg display plus up to 8 discrete LEDs and can also read up to 16 switches. The interface is 3 wires plus an optional interrupt for the switches. The downside is it only comes in an 24 pin SOIC package (no DIP). I've written a library for it if you are interested.

I suspect that Avago is discontinuing their LED clock module product line. Their product selector page no longer shows 4-digit displays and parts are hard to find. I had to switch vendors for my alarm clock shield.

That’s probably a good reason for using shift registers; but bear in mind that the pins you use for multiplexing the 7-seg displays can also be used for multiplexing buttons and/or rotary encoders. For example, if you are using 11 pins (without decoder) or 9 pins (with 2-to-4 line decoder) to drive a 4-digit display, then with one additional pin you can read 4 pushbuttons, or with 2 additional pins you can read 4 rotary encoders.


Thanks for the tip on the STLED316S - it looks perfect! I read the data sheet earlier and am going to order a couple right now so that I can test them out. Over the weekend I hope to work on my schematic, and once I have it I'll post it back here.

Okay, I made the schematic and board layout for my four-digit seven-segment display (data sheet: and the STLED316S driver (data sheet: that cjands40 recommended. I think I have it all right. It was my first time to create components in Eagle. I hope the footprints turn out correctly. I think they will.

Anyway, I had a couple questions that I was hoping an expert could help me with:

  • I could tell from the datasheet of the STLED316S if I needed to do anything wiht the unused pins (DIG6 / DIG7 / DIG1_LED / KEY1 / KEY2). It said they were “high impedance” when not used.
  • I had to use five vias to get my chips to fit on the little board (although I don’t think bigger would have helped a lot. I mounted the driver on the back of the board so that it would be easier to align the pins to the pins of the LED. I wish the LED pinout was a little more logical (digits on one side / segments on the other or something), but it all seems to work. Do you see any problems with the vias, layout, etc?
  • Not really a question - but I just realized that one of my standoffs is misaligned - so I’ll fix that before I export it for production.
  • Also, I want to label at least RSET resistor, if not all three of them. I just forgot.

Additionally, looking at the two data sheets I think that I calculated the following possible resistor values correctly for various brightness settings. Do they look right? They’re not the exact calculation, but the next closest “common” resistor value.

  • 150 ohms = 20 mA
  • 220 ohms = 15 mA
  • 330 ohms = 10 mA


LCDScreen-v1-board.pdf (75.9 KB)

LCDScreen-v1-schematic.pdf (27.4 KB)


Thanks for the feedback! Here’s some follow-ups (along with new PDFs).

1 - Great, thanks! That’s what I thought but I wanted a more experienced eye on it.

2 - Because I intended to use DIG1_LED to drive optional pins that can be used to connect external LEDs. I forgot to mention that before, but have the header pins updated in the attached drawings.

3 - I did the ground flood because on the last board I posted (my first board ever - last week -,72475.30.html) it was suggested that I always have one. I removed it on this iteration of this board. I don’t think it’s as critical on this board (but someone please correct me if I’m wrong). And when I added it I totally forgot to set the spacing so it wouldn’t be so close to everything.

I tried for quite a while to make it a single-sided board, but wasn’t able to after adding all my LED pins. I did make it happen without any vias, though, and only a single top-side trace. I’m pretty happy with that and this definitely taught me some lessons in routing. I wish I’d done this board before the one last week because now I know some better routing techniques. Oh well, I know I’ll be updating that board after I’ve built a few of the ten that are on order.

Oh, and yes - there’s a reason for the odd shape. I’m going to be using two of these boards (with the LED displays on them) inside an enclosure to build a chess clock. Since I’m ordering the boards from ITEADStudio, I can get 10 for $9.90 if I keep them less than 5cm x 5cm. So, I can’t make it quite big enough to support the entire (5.12cm) display without more than doubling the cost. Since they’ll be mounted in an enclosure anyway, it doesn’t really matter. I’ll have a cut-out the size of the display and then use stand-offs in the corners of the board to attach the display boards to the face of the enclosure. Well, that’s how it’s all piecing together in my head anyway. We’ll see what happens :slight_smile:

Anyway, new drawings are attached.

LCDScreen-v1-board.pdf (19.1 KB)

LCDScreen-v1-schematic.pdf (23.6 KB)

I would tie the unused inputs (KEY1 & KEY2) to GND through a 10K pulldown resistor rather than leaving them floating. Floating inputs are generally a bad idea. The unused DIGx outputs, however, can be left unconnected.

DIG2-5 are the best choice for a 4 digit display. (DIG1 has special features intended for discrete LEDs although it can also be used for a 7-seg digit). I'm sure we could start a pointless philosophical discussion over the correct order to connect the digits (endian wars!) but I'll refrain (for now ]:D)

I can't tell what design rules you used. Does it pass the DRC check? I personally would avoid routing signals between the SOIC pads including routes to the pads themselves (I used 12 mil traces with 8 mil spaces & 24 mil traces for Vcc). If you want to etch the boards yourself, you may need different rules If you are using a board shop, a double sided board with plated through vias shouldn't be an issue. My boards do use a flooded ground plane - no soldering issues given a proper soldermask. That's harder to do with a hand etched board, though.

Figure 8 in the data sheet shows the correct Rset values to use for your desired max LED current. 360 ohms yields 40 mA, 720 ohms yields 20 mA, and 1.4K ohms yields 10 mA. Remember that this is max current - you can dim the LEDs by writing to the chip registers (in 8 unequal steps).

If you don't already have enough of the Avago displays on hand, you may be forced to change your design. Other vendors (eg, Kingbright) have the same pin numbering but the layout is different (2 rows of 6 pins instead of Avago's 7 & 5). I learned this the hard way...


Thanks! I'll see what I can do to bring KEY1/2 down. I suppose they can go through the same resistor since they're not actually being used for anything, right?

I used the default rules and then the ITEADStudio rules (the folks who will be making the board). Both passed. I, too am concerned about the traces passing through the pads - primarily because I've never soldered anything so tiny before and there is a good potential for solder bridging. The traces are all 10mil, but my clearance between those pads is pretty small in a few places.

Maybe I'm just getting too sleepy but I have no idea how to read that graph in figure 8 of the data sheet, but based on your values I'll probably use the 360 ohms and then use the digital control to dial it back as needed. Did you look at the data sheet for the Avago displays? In the "Absolute Maximum Ratings" table it says "Peak Forward Current per Segment or DP" = 100mA and "DC Forward Current per Segment or DP" = 25mA. This is a dumb question, but what is the difference? How much should I be pushing? (I realize those are the absolute maximums and I shouldn't be touching them, but does that mean I shouldn't go near 25mA or 100mA?)

I ordered the displays - Mouser had them and I threw them in with my other parts order earlier this week, so I should have four of them arriving soon.

One pulldown resistor is fine for the two unused inputs. Also - you don’t need the pullup on IRQ since you aren’t using the keyscan functionality and are ignoring that signal.

Your traces will be covered by soldermask so you don’t need to worry about bridging to them. Solder bridges between pads are another story - you’ll probably get some depending on your soldering skill and the steadiness of your hands but they aren’t too hard to clear (solderwick and flux are your friend). I avoid coffee on soldering days!

I see no value in avoiding vias in a double sided board. That doesn’t mean go hog wild - just don’t create ugly routes to avoid them. I would move the routes from between the SMT pads but that is matter of habit for board manufacturability reasons. When you are only building a few, it probably won’t matter. If you have decided against ground fill, at least fatten up the Vcc and GND traces and make them as short as you can. It’s good to put the bypass cap close to the driver chip with short routes between the two.

Figure 8 has the 10, 20, and 40 mA cases highlighted in boxes. That may help you make sense of it.
Peak = do not exceed even for brief periods.
DC = do not exceed steady state.
In either case, give it some margin. The driver chip already multiplexes the digits so 40 mA (360 ohms Rset) should be safe. 4 digits plus discrete LEDs plus key scan time means each LED is on less than 20% of the time.

There is no reason to avoid ground plane. Once you have done the Ratsnest, Click the DRV button - then click on Distance and open it up some, click on clearance and open that up some, and click on Shapes and reduce Elongation form 100% to 80%, all will help to give you some more clearance between traces & stuff.

The unused KEY1 and KEY2 inputs shouldn't be left floating, but there is no need for a pulldown resistor, you can connect them directly to ground. The only advantage of using a pulldown resistor is that if you change your mind later and decide you want to use them after all, it's easier to change the circuit if they aren't soldered directly to a ground connection (i.e. you can remove the resistors).

[Historical note: with TTL logic, if you needed to make an unused unput HIGH then there was a good reason to use a pullup resistor instead of tying the unused input to Vcc, which is that the input voltage limit for inputs was lower then the voltage limit for Vcc. But this has never been the case for CMOS chips.]

Cool! I think I have everything. I’ve attached the latest - and hopefully last - revision of the board and schematic. I also exported them to Gerber and am checking the images that were generated at from my Gerber files. Hopefully it all looks right and I can send off the order later today.

Thanks for all the help!

Jeremy Thomerson

LCDScreen-v1-board.pdf (26 KB)

LCDScreen-v1-schematic.pdf (15 KB)

I don’t see a connection to the GND pin of the display driver - there is still a rats nest shown. You can move vias to open up a clearance for the ground plane to make the connection. And/or, you can put a GND fill on the top layer and add one or more GND vias between the two layers.

Good catch! I wish it popped up a big alert that said "you still have airwires". I'll fix this and submit the order.

Thanks to all! I'll update the forum as the project progresses.

cjands40: Take a look at the STLED316S - under $2.50 last I checked. It's a constant current LED driver (40mA) that can handle a 4 digit 7-seg display plus up to 8 discrete LEDs and can also read up to 16 switches. The interface is 3 wires plus an optional interrupt for the switches. The downside is it only comes in an 24 pin SOIC package (no DIP). I've written a library for it if you are interested.


My boards came in and I'll be soldering up my displays and STLED316S chips on them in the next few days. Sorry I haven't had time to post pictures of them, etc. I'll do all that soon enough. But I'm curious about your STLED316S library. I didn't find it with a quick Google search. Is it out there somewhere? I'd like to get ahold of it to start adapting my code to use it this week.



I haven't posted my library yet (soon!) but I can send you a copy now. I originally wrote the code with AVR Studio for a specific project; my Arduino version is fully functional but still hard coded to use port D pins (D0 to D7) for communication with the STLED316S. I'll publish it once I've removed that restriction. In the mean time, if you can tell me which pins you used to connect to the chip, I can easily send you a version for you to use now. Removing the pin restrictions should only affect private library functions so no impact to your code.