Take the 2-minute tour ×
Electrical Engineering Stack Exchange is a question and answer site for electronics and electrical engineering professionals, students, and enthusiasts. It's 100% free, no registration required.

I am working on a small test project for my Arduino and as part of it, I want to display a number on a 7-segment LED system. My first setup involved just direct links to the 7-segment display and controlling each segment individually with the Arduino by setting the output to LOW to activate it.

I then reduced the number of pins required to 4 (5 including the decimal point control) using a BCD to 7-segment High-speed CMOS chip (74HC4511) and connecting it as shown in the diagram below (the NOT gates are achieved through using NOR gates with one input connected to ground):

schematic

simulate this circuit – Schematic created using CircuitLab

I can then control the 7-segment display using the following snippet:

digitalWrite( 1, iVal & 0x0001 != 0 ? HIGH : LOW );
digitalWrite( 2, iVal & 0x0002 != 0 ? HIGH : LOW );
digitalWrite( 3, iVal & 0x0004 != 0 ? HIGH : LOW );
digitalWrite( 4, iVal & 0x0008 != 0 ? HIGH : LOW );
digitalWrite( 5, bDPRequired ? HIGH : LOW );

However, this isn't ideal as it still requires 4 pins; ideally I would like to reduce it to 1 pin which outputs the data serially. My first thought was to use some sort of 4-bit shift register; however, this would require another output pin to control the clock pulse, and would result in spurious displays during the transition from one number to another.

I'd be grateful for any potential ways I could minimize the number of pins!


PS: I am aware that it is somewhat bad practise to have the current-limiting resistor on the 5V output rather than on each of the cathode pins on the 7-segment display as it will result in less light emission the more segments are activated.

share|improve this question

2 Answers 2

up vote 6 down vote accepted

You could use a 74HC595 shift register and this circuit, courtesy of Roman Black.

enter image description here

That will buy you 8 outputs with a single 25-cent chip.

share|improve this answer
    
+1 Oh boy! That's really interesting!! I've always spent 3 output pins on those chips and wasted 2 without knowing. But does this setup operate reliably enough? –  Ricardo Apr 1 at 18:04
    
I would not use it to control a nuclear power plant, but assuming that it drives a display you can refresh it regularly, so a glitch has a limited inpact. –  Wouter van Ooijen Apr 1 at 18:19

The only was I can think to do this with only one pin is to use a 1-wire shift register, such as DS2408. This will give you 8 outputs using only one pin from your micro. However, I'd really suggest you go to two pins instead. This will allow you to either use a standard shift register or I2C to a GPIO expander chip as this will be much easier to program.

By the way, you have an error in your schematic. The resistor should be after your driver chip. Otherwise, its Vcc will drop in voltage along with the LEDs as more are turned on.

share|improve this answer
    
And preferrably it should be a separate resistor for each segment. –  Wouter van Ooijen Apr 1 at 17:54
    
The OP already commented on this so I didn't mention it. However, it is even worse as shown in this schematic. –  DoxyLover Apr 1 at 17:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.