Several 7-seg-displays via 2 PINs


Everybody knows 7-segment displays, if not from crafting things with an Arduino, then from everyday life. As the name already tells you – they usually have 7 different segments – or let us better say LEDs. They are available in very different varieties and most are a somehow the same, but different in terms of pinouts and how to actually controlling their output. You may want to take a look on Wikipedia for more information.

7 segment display varieties

7 segment display varieties

More details

The 7-segments actually correspond to only one digit of these displays. Sometime, they also include a dot that may be used as an 8th segment. However, controlling a single digit simply boils down to the following rough schematic of which each PIN A..G corresponds to digit’s segment and may be directly run by your Arduino on 7 (or 8) digital PINs:

7 segment display (wikipedia)

Four 7-segment displays @ 2 PINs

However, here comes the tricky part: Running e.g. four or even ten of such devices would require a lot of digital output pins. An easy way of controlling several devices via only two digital PINs is enabled by using shift registers. E.g. the 74HC299 is a universal register that may be used for parallel in-/output, but also might be turned into a serial-in, parallal-out register. The big advantage over some other regular registers is the possibility of cascading them. Voila, you only need an additional register for each digit.

74hc299 Pinout

74hc299 Pinout



Diode setup

diode setup

Arduino Code

At first, we need to set up our two PINs – one for a clock signal and the other one for actual data that should be loaded into our registers:

Furthermore, we need to define how to display a certain number – this will be indicated by each bit. This encoding very depends on how you build your setup. Do you shift left or right? Do you want to send the MSB or LSB first? How are your displays connected to their registers? – I am shifting right and use the LSB first. The character encodings then become:

Having these encoding, actually displaying a character is very easy:

Leave a Reply