Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

7-segment LED display using Arduino

  1. Aug 11, 2013 #1
    I want to make an LED display that can show 3 digits, so I have 7 segments for each digit for a total of 7x3=21 LEDs. I need this to display some data from a sensor I'm capturing with an Arduino, and I want to use the same Arduino to run the display.

    How can I do this without flickering the LEDs? The only way I could think of is to use 7 digital pins to display the digits 1 by 1 and just cycle through them very quickly. The problem is that this means the LEDs are off 2/3 of the time, and also they have to flicker which can't be good for the LEDs and the eyes (I'm speculating).

    Maybe there is some trick you can do, but I'm not familiar with electronics and I've thought about this for 4 days doing all sorts of designs with transistors and the bottom line is that I can't do it, it's like the hardest riddle ever.

    Any ideas?
     
  2. jcsd
  3. Aug 11, 2013 #2

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    A crude way would be to use latches to hold each LED on or off until you visit it next. Not good for large displays, perhaps, but for only 21 LEDs it would be a possibility.
     
  4. Aug 11, 2013 #3
    What problem? Google suggests that the normal way to do this is by multiplexing groups of LEDs tied together in common anode/cathode configurations. You'll need 10 pins on your uC.

    Lab11_Circuit_SevenSegmentMultiplexing-550x345.jpg

    Source: http://embedded-lab.com/blog/?p=2086
     
  5. Aug 11, 2013 #4

    jim hardy

    User Avatar
    Science Advisor
    Gold Member
    2016 Award

    At night in your room try moving your eyes about as if you were following a fast moving bug

    your eyes will likely pick up the flicker of your LED alarm clock digits.
    The eye normally can't see the flicker, it's too fast. But when the eye is moving it can see the flicker as a series of flashes.

    Same thing applies when driving in traffic at night, you'll see taillights on new cars flicker when your eye scans around the roadway.

    So let Mother Nature help you out. That's what gnurf's link is telling you - everybody's doing it.
     
  6. Aug 12, 2013 #5

    meBigGuy

    User Avatar
    Gold Member

    pulsing the display is how all led displays work, and how led brightness is controlled. Your eye integrates the pulsed light. Anything above 100Hz will be undetectable by most people. Note that the night adapted periphery of your vision is the most sensitive to flicker. Say you choose 100Hz, then you need to switch at 300Hz for each display to be 100Hz. The eye also is pretty linear in that you need 3 times the current if you are on for 1/3 the time.
     
  7. Aug 12, 2013 #6

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    Why would that be? Servicing three displays would only mean that the duty cycle of each would be 1/3 as long as if just one display was being supplied. So they would each be pulsed at 100Hz.
     
  8. Aug 12, 2013 #7
    An idea worth considering perhaps is using an 8-bit serial-In parallel-out register like 74HC595 for example (sophiecentaur suggested something similar if I am not mistaken). You will only need three pins on your arduino: data, clock and a signal to transfer the data you shifted into the register to the output pins which you wire to your display. The 74HC595 also has a serial out option so you can wire three of them in series and then shift in 24 bits. The 8 ones you shift in first will end up in the last HC595 in series, second 8 bits in the middle one and the last 8 bits in the first one. You then wire a 7 segment LED display to each of the shift registers and voila.

    Every time you will want to update any of the displays you will have to update all of them, but the other two will again receive the same data. Not a problem.

    Datasheet for 74HC595: http://www.nxp.com/documents/data_sheet/74HC_HCT595.pdf

    Cheers!
     
  9. Aug 12, 2013 #8
    I was going to suggest this very same thing. In general a great way to multiplex.
     
  10. Aug 13, 2013 #9

    meBigGuy

    User Avatar
    Gold Member

    if I turn each display on for 1 clock pulse at 100Hz it will be 3 cycles before I turn it on again. You know, display1 on for 10ms, then display2 on for 10ms, then display3 on for 10ms. So for a 100Hz clock, display 1 is on for 10ms every 30ms.


    The serial interface to load the segment values is a good idea if you want to save pins. If you want you can drive all the displays from a 21 bit (or 22 if you want to include the enable) serial chain, or alternatively include the 7 segments and the three enables as shift register output pins. Either way makes for a more complicated driver, but saves IO pins.

    Remember that the display pulse width is a cool way to control brightness.
     
  11. Aug 13, 2013 #10

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    I see where you're coming from now but, for only three segments, why ever would an Arduino limit you to one change every 'cycle'? Even the technologies of the '60s could have handled refresh rates much higher as that. Multiplexing display elements is only necessary when you are limited either by speed or the number of interconnecting wires. If you are suggesting that the driver for the three displays should be totally shared (which may be your reasoning) then I would say that's just not the right way to do it - particularly as a self-training exercise. Latches / registers rule for that application.
     
  12. Aug 13, 2013 #11

    meBigGuy

    User Avatar
    Gold Member

    Not sure what is wrong with the picture in post 3. Very simple, common example of what the OP was referring to. That is one way it is commonly done. The ONLY reason to go to serial drivers or other external components is because you need the pins for something else or have more complex drive requirements. But whatever one decides regarding IO, sequencing the digits in such a way is the way nearly every multi digit 7 segment LED display works.

    Regarding the frequency, generally processors are doing other things. A timer interrupt every 3ms to service the display is totally reasonable. No need to update it more often.
     
  13. Aug 13, 2013 #12

    sophiecentaur

    User Avatar
    Science Advisor
    Gold Member

    I agree about the suggested circuit. My problem was that you implied that a 3:1 reduction was necessary because of some speed capacity limitation. It's obvious that you need to put out information for three displays at three times the rate for one display but that doesn't mean you have to do it slower in this case. When it does become a problem, you just off-load that process to other circuitry. I probably misread your original meaning.
     
  14. Aug 13, 2013 #13

    meBigGuy

    User Avatar
    Gold Member

    I was saying that you need to switch at least at that rate or else it would flicker. I've read that some people can sense 200Hz flicker in their peripheral vision (anecdotal).
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: 7-segment LED display using Arduino
  1. 7 segment displays (Replies: 13)

  2. 7 Segment Display Help (Replies: 5)

  3. 7 Segment LED display (Replies: 7)

Loading...