cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting 3-digit 7-segment display (common cathode) to stm32

Matija1
Associate II

Hi everyone,

I’m planning to connect a 3-digit 7-segment common cathode display to my STM32 MCU. The display will be multiplexed, and I intend to use 2N2222 NPN transistors to switch each digit (common cathode). Each segment will have its own current-limiting resistor.

For safety, I’m designing for If = 10 mA per segment instead of 20 mA. I’ve attached my resistor and transistor current calculations (see attachment). I used 3.3 V as Vcc, because GPIO Output HIGH is 3.3 V. Ignore resistor value on shematic.

Could you please check if my calculations and connection approach are correct, and confirm whether using 2N2222 transistors is suitable in this case? I’m also a bit concerned whether 3.3 V will be enough to properly drive the display.

WhatsApp Image 2025-10-06 at 21.13.48.jpeg

Matija1_0-1759776516134.png

Matija1_1-1759778334404.png

 

 

4 REPLIES 4
gbm
Principal

1. What color? It makes a big difference. Ordinary low-brightness red is not a good choice.

2. NMOS logic level transistors will be better then npn. You will save on base current this way.

3. In low ambient light conditions (on-desk use) you may skip the transistors by setting the anode current to approx. 3..5 mA. This will work very well with high-brightness red, yellow and pure green despite what the display datasheet says.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

Thank you for your advice!
I decided to go with N-MOS logic level transistors (2N7000). Each transistor will have the drain connected to the digit (common cathode) pin on the display, source connected to ground, and gate connected through a 220 Ω resistor to the STM32 GPIO pin.

I am wondering if I should increase the current-limiting resistors on each segment, as I was using about 10 mA per segment—is that too high? Will the display still be bright enough if I use a higher resistor value?

Would the segments still light up well if I limit the current to around 5 mA using a resistor? In this case I would use ~250 ohm resistor.

Do you think this configuration should be fine?

WhatsApp Image 2025-10-07 at 11.21.31.jpeg

When it comes to brightness vs. anode resistors - you must do some experiments and decide on the proper value. The proper anode current depends on the environment - it may be anything between 2 and 30 mA.

2N7000 is not specified for logic level operation but judging from the characteristics it should work properly at 3.3 V logic levels with less-than 300 mA drain current.

Ideally, you should choose the transistor specified for Vgs of 2.5 V or less.

My STM32 stuff on github - compact USB device stack and more: https://github.com/gbm-ii/gbmUSBdevice

@Matija1 wrote:

Will the display still be bright enough 


only you can say what constitutes "bright enough" in your particular application!

As @gbm said, you are going to have to experiment ...

A complex system that works is invariably found to have evolved from a simple system that worked.
A complex system designed from scratch never works and cannot be patched up to make it work.