7-segment LED display using Arduino

  • #1
758
0
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?
 

Answers and Replies

  • #2
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.
 
  • #3
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. [...] 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).
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
 
  • #4
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.
 
  • #5
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.
 
  • #6
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.

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.
 
  • #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!
 
  • #8
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!

I was going to suggest this very same thing. In general a great way to multiplex.
 
  • #9
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.

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.


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).

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.
 
  • #10
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.

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.
 
  • #11
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.
 
  • #12
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.

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.
 
  • #13
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).
 

Suggested for: 7-segment LED display using Arduino

Replies
32
Views
1K
Replies
15
Views
337
Replies
3
Views
386
Replies
5
Views
801
Replies
5
Views
827
Replies
32
Views
2K
Replies
7
Views
1K
Back
Top