# Controlling multiple 7-segment LEDs with few GPIOs

I've got a simple single-digit 7-segment LED working properly (simply using 7 GPIO pins), but I'd like to scale it up to multiple digits and higher power. But I'd like to keep the number of GPIO pins to a minimum to leave some spare for other things.

I've seen a "BCD to 7-segment latch/decoder/driver" IC called a 4511, and this seems able to drive a single digit with a latch. So with 5 GPIO pins I can set a single digit. For four digits it looks like I'd need to either get four of these 4511 chips (total 8 GPIO pins), or I try to re-use the same IC for all four digits (total 9 GPIO pins plus a lot of work for the Pi and maybe flicker too).

I've also seen another "BCD to 7-segment latch/decoder/driver" IC called a 4543, and this seems to do the same thing except it says it's for "high voltage". And lastly I've seen a 16-channel TLC5940 which sounds like it could handle two digits at once, so I'd only need two of these chips (although more complex software to drive it).

There are two kinds of LED I want to drive with this, so it would be good if the solution could handle both. Firstly I want to just drive this tiny 4-digit display, so that's 3V and a few mA, no problem. But I also want to be able to drive some LED strips, and they're 12V with some tens of mA per segment. So whatever chip is driving this LEDs must be able to deal with higher voltages and higher currents, and I need to know how to limit the current properly (or get the driver chip to limit the current) too.

Additional info: The reason I suggested a TLC5940 "16-channel LED driver" for this is because the datasheet specifically says "Input voltage range Vcc = -0.3V to 6V; Output voltage range V(OUT0) to V(OUT15) = -0.3 to 18V", but on further searching there are examples where additional MOSFETs are needed to drive higher voltage LEDs.

I also looked at so-called power transistors instead of MOSFETs (as all the MOSFETs I could find were in single packages, hence lots required), but I read that these transistors were actually Darlington pairs and could generate a lot of heat, whereas MOSFETs are more isolating and hence more efficient.

Size isn't a big issue, but power, heat, cost and number of components are. So after reading about the TPIC6B595 "power logic 8-bit shift register" mentioned below, it seems well able to cope with this problem, and I only need 4 of these 20-pin chips, daisy-chained. And if I understand correctly, the chips will do the latching, so unlike the TLC5940s I don't need to continually provide a (very regular) clock signal to avoid flicker. And if I want to use a 7-segment display it has to be common anode for this to work.

I don't quite understand the output voltage clamp of 50V, can someone confirm that that's not going to be a problem when I plug 12V - resistor - LED - TPIC6B595?

A better alternative would be the `max7219`. It drives up to 8 7-segment displays (using multiplexing). It also has inbuilt current limiting. There are however quite expensive. You can however get them a lot cheaper on ebay.

Another alternative would be to use a shift-register per 7-segments. You can just daisy-chain these chips together, so you only need 2 or 3 GPIO pins. You however need to add current limiting resistors to all segments.

To drive the 12v led strips you have to use transitors or mosfets. These strips, generally, already have current limiting resistors on them. Are you going to build a 7-segment display using led-strips? I don't quite follow the last part of you question.

• Yes exactly, there are rolls of LEDs where you can split them into shorter lengths. So several of these lengths could be built into a 7-segment display and I guess controlled in exactly the same way as the little ones - except for the larger voltage. I'm hoping that's done by the "driver" part of the IC so the input can be low voltage but the chip is capable of powering the 12V strips. Or are you saying I'd need Pi -> driver -> transistors -> LEDs? Jan 3 '14 at 15:10
• The latter. I don't know of any chip that can communicate with 3.3v to the Pi, while powering 12V strips (though they might exist). In your case I would suggest going with shift-registers. As the max7219 is using multiplexing, which makes connecting the transistors the right way a whole lot more difficult. How big do you want to make the segments? How many leds? Jan 3 '14 at 15:49
• I'm not sure yet, but as I said one segment will draw several tens of mA, perhaps around 50mA at 12V. I do like the sound of the max7219, and it would be nice if the transistors didn't waste a lot of power. Are there mosfet chips which could deal with a few segments each? One per segment seems like overkill. The shift register would also need these transistors, right? Jan 3 '14 at 16:11
• white leds use around 20mA, so thats 20mA per 3 leds in those strips. Transitors don't waste a lot of power, though they have some voltage drop! The shift register also need transistors! You could use a darlington array chip like e.g. a `uln2003`. Those can sink up-to 500mA. `tpic6b595` looks nice, as it's a shift register with inbuilt fets. There are tons of chips out there. You'll have to look into the economics of buying such chips or just buying 7 mosfets per digit. And maybe size if there is a space constraint. There are many ways of making this. Jan 4 '14 at 15:14
• Thanks very much, it looks like your TPIC6B595 chips could be the answer (one per digit). I've never used shift registers before so it sounds like fun. Is it right there is no PWM control, each output is just either on or off (unlike the 5940s)? Although I could flash by toggling "G". Jan 6 '14 at 16:27

The TPIC6B595 will handle 12V LED strips with no problems. Dimming can be accomplished with PWM signal on the Enable pin. LED strips have their own current limit resistor per every 3 LEDs. Individual LEDs will need a current limit resistor each.

I offer a board with up to 12 TPIC6B59s, I used one populated with 8 parts to drive this display of 3 and 6 LED strips powered from 12V https://www.youtube.com/watch?v=6HZ0Mr51jUY