Understanding Seven-Segment Display Code

Hi all,

I bought a cheap seven-segment display from sparkfun here: 7-Segment Display - 4-Digit (Blue) - COM-09481 - SparkFun Electronics

...and while I have no problem getting it to work using the example code given here: http://dlnmh9ip6v2uc.cloudfront.net/datasheets/Components/LED/_7Seg_Example.pde

I'm having some difficulty just understanding the code in general. I do understand from the datasheet schematic (featured below) that the digits are turned on using pwm pulses within the code to control brightness/current flow to the leds and the segments required for each number is controlled with specifically defined digital pulses in a switch case.

But the thing I'm having trouble understanding is how the arduino controls the segments for each individual digit. The confusion comes into play due to the inputs on all the segments for each digit being all tied together as seen on the datasheet. If all the segments are tied together for each digit shouldn't every digit be the same? I know this isn't the case because I've tested the code and as far as I can tell it counts up perfectly.

If anyone could shed some light on this I would be quite grateful.

Hi, I think the concept you have not grasped yet is "multiplexing". Although it appears that all 4 digits are lit, in fact only one is lit at any instant in time. The digit that is lit is switched between the 4 at a speed too fast for the eye to see.

Paul

I do understand what multiplexing is but the part did not realize was that in actuality only one digit was being lit at a time. Makes a bit more sense now, thanks :slight_smile:

Infact... I just wrote some of my own code using the idea you just told me based on the example code just to test it out. To help anyone else out who might take a look at this thread, it basically it works just by turning one digit on, selecting it's segments then turning everything off, then selecting another digit turning it on along with it's segments. Because, like Paul said, the microprocessor moves so fast the display looks like it has two numbers but actually only has one number.