What happends if I turn on all LEDs at the same time in an 4 digit 7 segment display? that would be 32 LEDs turned on at once, wouldn't that exceed the 200ma MAX for the arduino output?
-
2Which 7-segment display? Different displays need different currents. The answer is in the datasheet for the display. Which Arduino? Different Arduinos can supply different amounts of current.– Mikael FalkviddOct 10, 2017 at 16:27
-
1Arduino uno. the 7 segment display is YY3641AH which I can't find a datasheet for.– TBGOct 10, 2017 at 16:29
-
And since there is no GND connected to the display, are all 8 segments of a digit connected trough one I/O pin as ground? Doesen't that exceed the pin's 20mA recommended level?– TBGOct 10, 2017 at 16:31
3 Answers
The key point is that if you do that, you're doing it wrong.
Typically a multi digit display is time multiplexed, such that you use a common set of segment lines to activate the pattern on each digit in turn, therefore at any one time only at most 7 (or 8 counting the decimal point) segments should actually be on.
Then in terms of the common connection which selects a given digit, this will indeed typically have to source or sink more current than an MCU I/O pin is typically rated to handle, so it's best if the common connection is driven by an external transistor or FET.
Other options of course include mutli-digit LED display drivers, or lower power display technologies like LCDs.
That said, if a software bug briefly means everything is on, chances are the chip will survive. But hopefully this only happens to "engineering units" - you do want to make sure that production units don't suffer this at some point in the programming process or something like that (though that's not all that likely, as typically all I/Os become inputs with at most a weak pullup).
These typically use 12 GPIO pins (4 for the digits, 8 for the segments/dot).
Each GPIO pin controls one digit and/or segment at a time.
The normal 'maximum' LED current is 20 mA. For the digits, 8 segments * 20 mA = 160 mA which is below 200 mA.
However, maybe there are LED displayed which use more current. In that case, you have yourself to make sure not all segments are lit at the same time (by fastly alternating the LEDs, or using less current).
-
1Thats what I'm worried about. Exceeding the individual 20mA amount for each of the 4 I/O pins used as ground, and exceeding the 200mA max for all pins– TBGOct 10, 2017 at 16:35
-
1when I light up 4 leds they seem to pull 40mA. What about all the 32 then?– TBGOct 10, 2017 at 16:36
-
1
-
1but all that goes trough one I/O pin which is used as GND for the digit. Thats double the max rating for the pin.– TBGOct 10, 2017 at 16:42
-
1well, for me each LED uses 10mA, so if I set one digit to show a "8." thats 8x10mA= 80mA that go trough one GND I/O pin.– TBGOct 10, 2017 at 16:47
They will turn on, likely with slightly uneven brightness - the LEDs internal resistance and the pins limited current drive will act like the current limiter.
The actual current will depend on the supply voltage, led used and the mcus drive capabilities.
For a red 4 digit 7 seg on an atmeha8, I got less than 10ma at 2,5v and 20ma at 3.3v, with the LEDs multiplexed.
Edit: some quick math.
Say that the current through each led segment is I. And the gpio resistance is R.
Each common digit has 8 I current through it, and each segment has 4 I. Some math later,
I = (Vcc - Vf) / (12 R) where Vcc is the supply voltage and Vf is the LEDs forward voltage (1.9v for a typical red led). The gpio resistance varies from 50+ ohm to 30+ ohm, higher at lower voltage.
Plus in 3.3v and 2.7v you get total current of 30 to 75ma for all digits.
I'm going to measure mine later.
edit: about 25ma (total current = mcu + led) at 2.5v and 50ma at 3.3v. the mcu consumes 2-3ma approximately.
the brightness is fairly even amongst the leds if you don't look too closely.