# Driving 7 segment displays through Raspberry Pi's GPIO

So I was thinking of wiring up four 7-Segment displays through the Raspberry PI. I'd do that by multiplexing each of them, and came across this: http://hackyourmind.org/public/images/display7seg_anim.gif

The thing is, I'm aware that I can draw (and sink) a max of 16 mA per GPIO pin. Therefore I can only have a max draw of 16mA for each segment correct? (assuming I don't use a transistor for each segment to draw power from the 5v rail). So, if I'm only drawing less than 16mA at any given time, do I need those transistors to switch the multiple displays on and off? Can't I wire each of the common anodes/cathodes directly from the GPIO pins and just switch them high and low to turn them on and off?

EDIT: I'm also pulsing each of the segments of each display so I don't need 7 resistors per diplay and can get along with just using one resistor on the common anode/cathode and keep the brightness across different digits (is there a better way to do this?)

## 2 Answers

If you pulse each segment of each display (at each moment in time only one segment of each digit is on) you indeed don't need any transistors, and you can use a single resistor per digit.

The downside is that the average brightness of each digit will be only 1/8 of its 'full' brightness. If you use a high-brightness display this will likely be no problem. (note that in the gif you linked to the brightness is 1/4 of the maximum, because only one digit is activated at each moment in time).

• I am missing the 1/8 derivation, could you explain please? EDIT: Oh wait, I missed the part about only one segment of the 7 at any moment. Is this what you were referring to? I've never seen it done like that before. The projects I've seen are just like the gif and drive up to 7 LEDs at once and multiplex which display is being driven - rather than drive each of displays up to 8 times so only a single LED is driven at any moment. Jun 25, 2014 at 2:51

Each segment will only draw 16mA, but the common pins will draw enough current for all the related segments. Put transistors on those.

But not resistors, since the current through all segments will be constant, which means that the current through each lit segment will depend on how many segments are lit. Just keep the multiplexer moving, and that will restrict the power applied to each segment.

• Your answer implies resistors for each of the segment pins right? Read the edit to my question Sep 23, 2013 at 12:06
• No, it doesn't. Read the last sentence of my answer. Sep 23, 2013 at 12:07
• So let's assume I'm using common anode. I drive HIGH through the common pin and no type of resistor anywhere?Assuming i drive only one segment, won't it be trying to sink like 50mA from the 3.3v rail into one GPIO pin, frying it? Sep 23, 2013 at 12:12
• The first paragraph covers that. Sep 23, 2013 at 12:15