This is a followup to my question https://arduino.stackexchange.com/questions/98809/difference-between-using-gnd-and-digital-low-for-7-segment-display-pin which should've been asked here as it turns out not to be unique to arduino's pins.
I am using this 4-digit 7-segment display.
So my circuit is basically 220 ohm resistors for all the segments (display pins 6 through 16 on the bottom each go through a resistor before going to a digital output pin on the arduino)
I read online that each segment should have its own resistor instead of having one resistor for all to maintain even brightness. The segments are rated for max 25 mA. Assuming the digital pins output 5V, this requires resistance of 200 ohms I think? Well I don't really know because there are multiple resistors in parallel. I don't understand how the current per pin adds up.
Display pins 2-5 are directly connected to arduino digital pins 2-5. The reason I did this was so I could multiplex which pin is LOW for each digit.
I received this answer, which I have several closely related followup questions for on the calculations.
Each LED has a "forward voltage" that depends on the specific model, roughly on its color and technology. The data sheet tells us 4.0 V typically at 20 mA (for the digits, as they have 2 LEDs in series). It raises with the current, but not linearly, to about 4.05 V at 25 mA. Please be aware that these are typical values, the concrete values can differ a lot!
Assumed that the Arduino's pin would output 0 V for LOW and 5 V for HIGH, which is idealized, the remaining voltage at the resistor is about 1 V. Divided by 25 mA results in a resistance of 40 Ω.
Do we divide by 25 mA if we wanted to use that current and find the resistance? Suppose I made no changes and left my 220 ohm resistor. Then the current across the LED is 4.5 mA, which is way below the max, correct?
Now the multiplexing comes into play. Since you use 4 digits, most probably each of them is driven roughly during 1/4 of the time. To have the average of 25 mA, you need to multiply the current by 4, giving 100 mA. The resistor will have 10 Ω then.
For multiplexing, does it mean "multiply by 4 to get the same average current as if the digit were continuously powered?" Otherwise, I don't see why I would need an average 25 mA across an entire multiplexing cycle. My thought was that 1/4 of the time, there is 25 mA through the segments, then 3/4 of the time it is off. The brightness is fine for my purposes.
When multiple segments are on per digit, the HIGH side of each segment still carries 100 mA as calculated above. But on the LOW side (the common cathode) the current is the sum of all driven segments, up to 7. Outputting an "8" will result in 700 mA!
The pins of your Uno cannot source or sink a lot of current. If you try to do more, real world effects according to physics jump in and make the mental model invalid. According to this answer on SE/EE, the maximum current per pin is 40 mA.
If the current is higher, a LOW will not hold the voltage near GND. It will be significantly higher. The same is true for HIGH. The data sheet of your Uno's MCU will tell you more, look for "pin driver strength".
This reduces the usable voltage on resistor and LEDs. This leads to less current, until some balance point is reached. Please be aware that you are using the device outside the specifications here, which could damage it permanently.
If each arduino COM pin can only provide 40 mA, then when outputting an "8" each segment will only get 40 / 7 = 5.7 mA. Is it saying the circuit will change LOW voltage until it gets say 25 mA per segment, or the segment will simply only get 5.7 mA? I don't think I am pulling anywhere near 700 mA in this whole display.
Edit: I expected the 4.5 mA would be dim, but it's actually reasonably bright. I tried measuring the current but I think my multimeter is broken for current because it reports 0.0 mA always. I also tried voltage and found 1.6 V, which would make Vf about 3.4 V.
per pin
specification. But there should also be aper port
limit spec, as well. And perhaps also an overall spec for the MCU. Have you checked all this? Also, the port pin doesn't know what you are doing. It just responds. If you are trying to sink current in excess of its ability, what happens is that its voltage rises until there's no longer a problem. Which also means less current. But not in a predictable way, when exceeding. \$\endgroup\$