# How to wire up 4-digit 7-segment display?

I have an Arduino Mega and the CL5642BH, a 4-digit 7-segment display. I found very helpful code here, but I don't understand how to wire it up on the breadboard.

The display has 12 pins: 6 on the top and 6 on the bottom. First I guess I need to find out which one is GND.

Then (see the link) there is this code:

``````int digit1 = 11; //PWM Display pin 1
int digit2 = 10; //PWM Display pin 2
int digit3 = 9; //PWM Display pin 6
int digit4 = 6; //PWM Display pin 8

int segA = A1; //Display pin 14
int segB = 3; //Display pin 16
int segC = 4; //Display pin 13
int segD = 5; //Display pin 3
int segE = A0; //Display pin 5
int segF = 7; //Display pin 11
int segG = 8; //Display pin 15
``````

It's 11 pins, that's the correct amount so far. But how do I wire it up? The pins on the display are in no way labeled.

Note: I'm a software developer, but as far as electronics go, I'm still a beginner.

The first thing you do is ask Google for a datasheet. It tells you: http://www.robotshop.com/media/files/pdf/datasheet-com-09483.pdf

Then you can read the datasheet and find the pin diagram:

That tells you that it is a Common Anode LED display - which means that for each digit all the Anodes (positive pins) of the LEDs are wired together.

Further, all the cathode (negative) pins of the LEDs for the same segments across the digits are connected (that is the cathode for segment A on digit 1 is connected to the cathode for segment A on digit 2, digit 3 and digit 4, etc).

From that you can then infer that you need to provide current for each digit in turn through its common anode pin, and sink current from the segments you want to have lit for the digit that is currently having its current sourced.

The diagram also shows you which pin on the display is for what function - the common anodes are pins 9, 10, 12 and 13, with pin 11 the common anode for the extra dots.

The datasheet also tells you which pin is pin 1 - in this case the one in the bottom left when you have the display facing you and the numbers the right way up. The pins count anti-clockwise from there, so 2 is to its right and 13 is above it.

By the sounds of it though you may not have the same display as in that datasheet. If your display lacks the extra dots then it may not have the LEDs on pin 11, and pin 12-13 may be moved down one, so you have 4 commons on 9, 10, 11 and 12 with no pin 13.

So the four digit select pins in your program are wired to pins 9, 10, 12 and 13, and the segment select pins connect to pins 1, 2, 3, 4, 5, 6, and 7. Don't forget the resistors on all the segment pins to limit the LED current or you will damage the Arduino.

You can do some manual testing of the display by using two wires and a resistor (say 1KΩ). Connect the resistor to +5V, and one wire to the other end of the resistor. The other wire you connect to ground.

You then take the loose ends of the wires and try probing pins. Start with the 5V wire touching pin 9 and connect the other one in turn to pins 1-8 to see if the first digit's segments light up. Repeat with the 5V wire on pins 10-12.

Edit:

If this (http://mklec.com/displays/7-segment-4-digit-12-pin-common-anode-display) is indeed the same display as yours you can ignore the numbers I mention above and work from the pin numbers on that page. The same principle applies though, just the pin numberings are different.

• This clears things up a lot. And I also found a wiring description. Unfortunately it's in German, but here it is anyway: ecotronics.ch.honorius.sui-inter.net/wordpress/2013/… – bytecode77 Aug 22 '15 at 20:15
• @bytecode77 Don't follow his wiring instructions, they are wrong. He has 4 resistors, one on each anode. You need 8 resistors (7 without DP), one on each cathode. – Majenko Aug 22 '15 at 20:19
• Oh... Well, I'm very confused by now. Do you have some sort of idiot's guide to wiring this display? – bytecode77 Aug 22 '15 at 20:20
• @bytecode77 Wires from IO pins to anodes. Resistor on each cathode. Each resistor to IO pin. – Majenko Aug 22 '15 at 20:21
• What? Look, I'm really a beginner in electronics. I have trouble with the simplest things. Do you have some sort of guide? – bytecode77 Aug 22 '15 at 20:23

As page 2 of the datasheet shows, there are 5 anode pins (4 digit and 1 aux) and 8 cathode pins (7 segments and 1 DP). Connect the digit lines to the digit anodes and the segment lines to resistors connected to the segment cathodes. The location of pin 1 is shown on the top right of page 2, and as always they go counter clockwise from there. Segments are lit by putting the anode high and the cathode low.

• But why does the data sheet show 16 pins when I only have 12? – bytecode77 Aug 22 '15 at 19:53
• Probably because that's not the correct datasheet. – Ignacio Vazquez-Abrams Aug 22 '15 at 19:54
• @bytecode77: This would appear to be more accurate. The same principles apply, just the numbers differ. – Ignacio Vazquez-Abrams Aug 22 '15 at 19:56

From the datasheet found by Ignacio Vazquez-Abrams:

Now one segment will light up if there is a positive (eg. 5 V) on the anode, and a negative (eg. ground) on the cathode. You need a resistor (eg. 330 ohm) to protect the LED and the output pin.

Hopefully it is clear from the original question which Arduino pins go to which LED pins.

Then the code which I presume you found will have to multiplex the display. That is, it will ground (send LOW) to the appropriate cathode pins for the number of segments it needs to light up (all of them, for example, for the number 8, except the decimal point). And then it will raise to 5 V (send HIGH) to DIG 1. That will make some segments on digit 1 light up. Then it repeats that for digits 2 to 4, fast enough that they will all appear to be on at once.

Apply the pin 1, 2, 3 with 5v from Audrino passing through the resistors. Apply low voltage to pin-a to light up the led, so on so forth. You can use the multi-meter to confirm the common pins and led pin. For example touch the pin1 with (+) and pin-a with (-) of the multimeter. If the pins are correct, led pin-a will light up.

Picture Reference:http://www.circuitstoday.com/voltmeter-using-arduino