I'm designing a velocimeter and I'm having doubts about the display's brightness control.

I have an ATTiny 2313 microcontroller connected to a CD4511 that drives a common-cathode 3-digit 7-segment display. On the MCU, 4 GPIO pins set the digit pattern and 3 GPIO pins select the digit through the transistors.

I'd like to have a potentiometer to control the display brightness. My first thought was to connect it to the display cathode, but each number in a same digit will be of different brightness.

Second thought was to connect it to the CD4511 5V pin, but I don't know if it will mess up the internals (the minimum is 3V).

Does anyone know a better way?

  • 1
    \$\begingroup\$ Use PWM for controlling the transistors that drive the common cathode. \$\endgroup\$
    – StarCat
    Apr 7, 2022 at 21:22
  • \$\begingroup\$ Do you have current limiting resistors between CD4511 and LED anodes ? If not try Changing from 5V to 3.3V and report back if acceptable \$\endgroup\$ Apr 7, 2022 at 21:57
  • \$\begingroup\$ Will try that @StarCat. // I want to change brightness on the go for better visibility in day and night, can't fix the resistor values Tony Stewart (besides the protection resistors between LED and micro) \$\endgroup\$
    – Elías D
    Apr 7, 2022 at 22:16

2 Answers 2


The answer to

how do I control brightness of LEDs if I have microcontroller

almost universally involves PWM.

In your case, turn the STROBE input of the CD4511 on and off quickly, typically using your ATTiny's PWM unit.

If you need a poti to control the brightness, use it to generate a DC voltage, and use the built-in PWM comparator of the Attiny to convert that voltage into a PWM duty cycle.

I might add that using a microcontroller with an ADC might be easier. Replacing the very weak and feature-poor, but pretty expensive Attiny2313 with a microcontroller that has 10 free GPIOs (instead of 7 you need) would immediately allow you to get rid of the CD4511; it really makes no sense to use a BCD-to-7-segment IC in 2022, your microcontroller is perfectly capable to convert numbers to segments to light up, this isn't the 1960s. BCD is not a native format for any electronics these days.

  • \$\begingroup\$ Thanks for the answer. I picked the Attiny 2313 because I'm building a velocimeter with a GPS module that communicates via UART, and that micro has UART and it's cheaper than an Arduino or a Pico. I'll probably drop the 4511 too, I wanted to use it for the sake of it. \$\endgroup\$
    – Elías D
    Apr 7, 2022 at 22:10
  • \$\begingroup\$ literally any microcontroller of the last 30 years has one or more UARTs :) it's a pretty unexciting mircocontroller indeed. A relatively cheap source of well-programmable microcontrollers are so-called "Blue Pill" arduino-compatibles. Or go with an official eval board, that brings much nicer programming tools built-in: e.g. de.farnell.com/stmicroelectronics/nucleo-f303k8/… or digikey.com/en/products/detail/NUCLEO-F070RB/497-15095-ND/… \$\endgroup\$ Apr 7, 2022 at 22:33

You did not mention resistors that are needed using 5V, but each driver has resistance which is increases with lower Vdd, and rising temperature. from the datasheet, enter image description here

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.