Proper wiring of a 4 digit 7-segment display

 Posted by:   Posted on:   Updated on:  2018-12-14T19:29:52Z

How to connect 4 digit multiplexed 7 segment displays to Arduino development boards. You need some current limiting resistors and driver transistors.

Seven segment displays are widely used in clocks, meters and other devices that need to display numerical information. The elements of the display, which are usually made from LEDs, are lit in different combinations to represent Arabic numerals. They have a limited ability to display some characters because there are only 7 elements that compose the shape of the displayed figure.

Seven segment displays are very easy to find and are the cheapest display type. Nowadays, modules with such displays do exist, where a display of 4, 8 and even more digits are driven by an integrated circuit. This driver gets the digits to be displayed from a microcontroller (MCU) via a serial bus. This saves a lot of pins and makes programming easy since all modern MCUs have support for the common serial protocols. Examples of such ICs are MAX7219, TM1637 and TM1638. The latter two come with support for keypad, therefore you can build front panels with buttons and display using such ICs.

Proper wiring of a 4 digit 7-segment display

But this post focuses on plain 4 digit 7 segment displays that do not have a driver. They are just a bunch of LEDs wired together in a specific configuration. Since they are very easy to get, many people are interfacing them with a development board (usually Arduino). Let’s see how you should, and mostly how you shouldn’t connect a 4 digit display to Arduino.

These devices have 4 digit made of 7 LEDs plus an extra LED for the decimal point next to each digit. That’s a total of 32 LEDs that Arduino should be able to turn on and off independently. But if you look at a display, it has only 12 pins. How it’s that possible? Well, the digits are multiplexed. You have four common pins, one for each digit. When one of this pin is active, you have control over a single digit using 8 pin interface (7 segments + decimal point). Digits are lit sequentially, in rapid succession and perceived as being always on. Four common signals and eight segment pins gives a total of 12 pins. Have a look at the schematic.

Schematic of common cathode and common anode 7-segment displays

Schematic of common cathode and common anode 7-segment displays

Depending on common pins wiring, the displays are of two types: common cathode where a digit’s segment LEDs are connected by cathode to the digit selection pin and the common anode. Look at the schematic. There are nothing else than LEDs. No current limiting resistors, no transistor drivers. That means we need to add them when interfacing this to Arduino (or any other development board or MCU).

Some people use no resistors because they drive digit pins with PWM signals. Is that a good approach to save some resistors? Not at all. The LED is a diode and the current drawn by a diode rises exponentially as a function of voltage. It’s not possible to generate the correct PWM that will avoid higher than rated currents flowing through the LED without some sort of feedback mechanism. Implementing such a loop is way more complex than adding a resistor. You may get it working without resistors, but you are operating the LEDs outside their safe ratings and you overload the MCU driving pins. For more information check this discussion.

Others added resistors only to digit pins. There are two problems here. When only one segment is on, everything is fine. But if you turn on more segments, current drawn on digit pin increases. So does the voltage drop on resistor. Overall, LED intensity decreases with the number of segments turned on. And what’s the current drawn from MCU pin that drives the digit? Assuming 10 mA per segment LED, you get 80 mA which could damage the MCU.

The proper way to connect a multiplexed seven segment display to a MCU is by driving digit pins with transistors and each segment should be current limited with a resistor. This increases bill of materials, but as I said in the beginning you have the option to use a display module with serial driver. I ended up writing this post mostly because of the numerous projects on high ranked sites that show direct interfacing.

Connection of multiplexed display to Arduino

Connection of multiplexed display to Arduino

Usually any general purpose transistors will do for the drivers. Common cathode displays are driven by NPN transistors with emitter tied to ground, while common anode displays are driven by PNP transistors with emitter connected to supply voltage.

Current limiting resistors on segments should have at least 220 ohms for 5V supply. Next time I'll identify the pins of an unmarked display and wire it on the breadboard. The pin numbering in the above schematic is not the same for all displays.

4 comments :

  1. what transistor you using ? i need to calculate base resistance

    ReplyDelete
    Replies
    1. I used 2N2222A with common cathode display, but you can use any general purpose small signal transistors.

      Delete
  2. Can BC556 be used for a common anode display type?

    ReplyDelete
    Replies
    1. Yes, it is quite similar to BC557 and it can be used.

      Delete

Please read the comments policy before publishing your comment.