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