2025-10-06 12:24 PM - last edited on 2025-10-07 5:13 AM by Andrew Neil
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.
2025-10-06 12:56 PM
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.
2025-10-07 2:39 AM - edited 2025-10-07 3:44 AM
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?
2025-10-07 3:36 AM
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.
2025-10-07 5:18 AM
@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 ...