I recently got a 4-Digit 7-Segment LED Display from Sparkfun, and couldn't wait to use it. Here, I will show you how to wire it, and some sample programs to use with it!

Step 1: Display Info

This is the way the display works. It's multiplexed, so you select the digit by setting its pin (we'll get into pins later) HIGH, and you select the segment by setting its pin LOW. You display multiple digits at once by rapidly cycling through them.
The Pins (digits are numbered from the left):
Digit 1: 1
Digit 2: 2
Digit 3: 6
Digit 4: 8
Segment A: 14
Segment B: 16
Segment C: 13
Segment D: 3
Segment E: 5
Segment F: 11
Segment G: 15
Decimal Point: 7

Step 2: Wiring the Display and Button

Now, to wiring! To make it easier for you, I am going to put the Arduino pin number first, then the display's pin number.
9--1 (resistor)
10--2 (resistor)
11--6 (resistor)
12--8 (resistor)

If this is too confusing, say so in the comments, and I'll rewrite it.
Connect the button to Arduino pin 13 and 5V.
I used 1K resistors, but you could get away with less.

Step 3: Programming

I'm pretty much just putting refrence links and files here.
Display Datasheet

Timer Program (I modeled my timer after this)

Attatched Files:

_4segTimer: Timer program

_4digitAni1: Animations

The programs still need some tweaking/additions, so I'll be updating them once in a while.

Update History:


<p>There are only 12 pins on the display but your connecting pin 1 on the Ard to pin 14 on the display.... very confusing.</p>
<p>same here</p>
<p>some down in the comments:</p><p>1--10 (a)<br>2--7 (b)<br>3--4 (c)<br>4--2 (d)<br>5--1 (e)<br>6--11 (f)<br>7--5 (g)<br>8--3 (dot)<br>9--12 (resistor) (d1)<br>10--9 (resistor) (d2)<br>11--8 (resistor) (d3)<br>12--6 (resistor) (d4)</p><p>10 and 11 reversed for me</p>
<p>Tip: If you have 12-pin segment display your scheme will be like this:</p><p><strong>1--10 (a)<br>2--7 (b)<br>3--4 (c)<br>4--2 (d)<br>5--1 (e)<br>6--11 (f)<br>7--5 (g)<br>8--3 (dot)<br>9--12 (resistor) (d1)<br>10--9 (resistor) (d2)<br>11--8 (resistor) (d3)<br>12--6 (resistor) (d4)</strong></p>
<p>Used the same, except of 10 and 11, I reversed it. Using (sh)5461as panels.</p>
i got it working, it is a 4 digit seven segment i got from an old DSTV Decorder, and controlling it over the serial monitor
<p>thank you</p>
i has download it,but cant open in arduino IDE because that file is not pde
<p>Does the 4 digit file is the part one of the Segment?</p>
<p>I dont get it how to wiring ?! Can anyone sent schematics or smth ? Thank You :) </p>
<p>yeah could we get a digram ?</p>
<p>People should also be aware that there are differences when wiring CC (Common Cathode) and CA (Common Anode) 7-Segment displays, as well as addressing them with the code, or using shift registers / led drivers.</p>
<p>To get the timer to work do I just copy and paste the file into the Arduino program?</p>
<p>please can you post the circuit diagram ?</p>
<p>Could I possibly get a list of comments for what's happening in either the timer or animation program? I'm using a 4 digit display for a heart rate monitor and I want to know how I can display the BMP from my Arduino. </p>
<p>It runs also with an ULN 2803 instad of the 4 transistors. where can i buy in europe the sma420564 ? I have only one in my arduino kit. mfg CK</p>
<p>I am using an Arduino Mega 2560, and I am using analogWrite intead of digitalWrite because I don't have low value resistors at the moment :(</p><p>1: the button doesn't work, maybe pin13 is cursed on my board + i like using the LED for error reporting. if you used other pins it won't work without a pull-down resistor, or reversing the code and using the internal pull-up. I suggest:</p><p>in setup(). add: pinMode(xx, INPUT_PULLUP)</p><p>in loop(). change: if (digitalRead(13) == HIGH) to: if (digitalRead(xx) == LOW)</p><p>and the button connects between <strong>pin and ground</strong>. (xx any pin other than 13 ).</p><p>2: the digits were reversed ie: it was counting from left to right. I suggest:</p><p>int d1 = 9; int d2 = 10; int d3 = 11; int d4 = 12;</p><p>instead of: int d4 = 9; int d3 = 10; int d2 = 11; int d1 = 12;</p><p>3: Thank you for the instructable :)</p>
<p>I smell spam, or you're just someone who doesn't understand the differences between my project and the one you linked.</p>
I wasn't able to get the program to count, all it did was light up all the segments. Do I need to add a certain library in order for it to work?
Did you use the right program? One just lights up random segments, and the other one is a timer.
YEs, I am using the timer program. You are using the Arduino uno right?
<p>Actually he appears to be using a duemilanove, will test on my UNO later</p>
Could you help me please?<br>My LED display hasn't got the [ : ] (those two dots) so it has got less pins, only 12 (6 in each side). How do I do the connections?
Hello can anyone please help me with codes for <br>a counter down timer of 10min and 59 sec which will be running on a seven segment led <br>with two button for (stop/resume) also one for reset <br>it will count down until it reaches 00:00 when it reaches zero it has to gives a buzzer sound for just three second
how to connect the colon on the display <br>Thanks
can you help me to understand how you noted the pin out from the arduino board ? <br>there is no 14, 15 ,16, tell us the pin name as mentioned on the arduino board <br>thanks i am stuck to continue
The numbers in the left column are the pins on the Arduino itself. The numbers in the right column correspond to the pins on the display (which will be different if you have a different display).
The resistors should be on the SEGMENTS, not the DIGITS (IE: pins 3,5,7,11,13,14,15,16). The way this is wired, there would be 3.5 X the current through a resistor when displaying an 8 as when displaying a 1, and this will result in brightness fluctuations. Thanks for the rest of the information though.
There is no need to put the resistors on the segments instead on the common contacts!<br> <br> You can choose whenever you like to put your resistors to. The point is to change appropriately your algorithm. Just imagine that you chose segment first an then choose a digits it should shine. Then continue with next segment.<br> <br> Actually I did it today cause I forgot my 1k resistors, having only 2 of them I was able to test two 14 segments displays.<br> <br> General rule is. If it do not work, turn world upside down. If it still do not work, turn world inside out. :-) :-) :-)
If you are lighting more than one segment at a time (IE: if you are turning on all 7 segments to make an 8) and not DRAWING the 8 by rapidly sequencing each segment (lighting only one segment at a time in rapid succession, so that persistence of vision makes you see the whole digit 8) then the resistors need to be on the segments, otherwise the 1 resistor gets more current through it the more segments are lit - and your display is much dimmer making an 8 than a 1. Since this instructable makes the whole digit, you need the resistors on each segment. If the code were changed so that it was &quot;drawing&quot; each digit, then yes, you could get away with 1 resistor per digit without suffering brightness loss - however this method takes much more programming and processor resources.
I'll draw an analogy. Lets say you have a 2 inch water pipe, and it has to feed the 8 taps in the house. The taps need a restricted water flow though, or the washers will blow out. What we do, is we reduce the 2 inch pipe to &frac14; inch right before each tap. This ensures the tap get maximum water flow without danger. We can turn on all the taps without problem since all 8 are being fed by the 2 inch pipe before the flow is reduced at each tap. <br> <br>Now lets imagine a rookie plumber shows up, and he doesn't have eight &frac14; inch reducers - so he decides to just reduce the 2 inch pipe to &frac14; inch with one reducer, and then feed the 8 taps. Well, it works fine when 1 tap is on - it gets the most water you can put through the pipe and everything is fine. <br>But then the whole family comes home from camping and they all need to wash - so all 8 taps are opened at once. Well, now we are trying to feed 8 taps with only a &frac14; inch feed - and all the taps suffer and only get 1/8 of the water that they can handle. Yes, there's still water at all the taps - so technically &quot;it works&quot; - but it doesn't work well, because it wasn't done right!
To further this explanation - lets say that a 2 inch pipe allows a maximum flow of 8 gallons a minute. The taps can only handle 1 gallon a minute, or they blow a gasket. We need to reduce the flow from 8 gallons a minute to only 1. This means we have to divide the flow by 8. 2 inches divided by 8 is &frac14;. so a one quarter inch pipe will allow only one gallon per minute to flow. This is perfect for a single tap. With all 8 taps on, since the 2 inch pipe can allow 8 gallons a minute, and each tap is restricted to 1 gallon a minute, this is perfect, even with all taps on. If we reduce the flow to 1 gallon a minute first, and then feed that to all 8 taps, since the maximum flow for all 8 taps is a total of 1 gallon a minute, the 8 taps now have to share this, and each tap only gets one eighth of a gallon per minute. I hope that clears it up.
Oh, I noticed the brightness changing. Thanks for the tip; I'll make a second version of this including this modification.
I suggest about 220 ohm.
now how to make a simple countdown timer from 30 sec and after it hits zero a buzzer goes off... any ideas?
You could probably write a program where you set a variable and it subtracts 1 every second, then *if* it equals zero, *then* sound a buzzer. You would need to call a separate function that deals with displaying the variable's value on the display.
you could make a timer count down and then you can have a piezo buzzer go off
where dous ground cume from?
On the display? Power comes in through the digit pins, and goes out through the segment pins.
thank you- i got it working for the blue color with 110 ohm resistors. <br>for the counter code, to get the right side digit to display the second i flipped the DIGITs order from your code: <br>//int d4 = 9; int d3 = 10; int d2 = 11; int d1 = 12; <br>to: <br>int d4 = 12; int d3 = 11; int d2 = 10; int d1 = 9; <br>now it displays correctly with the fast counting digit to the right side, decimal second to the left etc.
thanks for the tutorial! I see resistors in the pictures but not on your pin connection list. where should i put resistors and what value? thanks a lot
Sorry, use the resistors instead of jumpers on pins 1, 2, 7, and 8 (the display selection pins). I used 1K resistors, but you could get away with something less.
How do I use the pushbutton to pause the counter rather than reset it?
That is not currently in the program. You could have it set up where it only counts if the button is not pressed, for example: <br> <br>void loop() { <br> buttonState = digitalRead(13) <br> if (buttonState == LOW) { <br> [insert counting program here] <br> }
Thanks. I was thinking of making a basketball game timer and also need to use the &quot;:&quot; that could count to 30:00 minutes or down from 30:00 to zero and pause for fouls with a push of the button. I have another display for the score but not sure one Arduino could program both displays...
So you'd definitely want to replace the button with a switch, so you don't have to hold the button down. If both displays show the same thing and have the same pin configuration, it shouldn't be a problem as long as they don't draw too much current (probably not, since they're cycling through and not constantly on). Would you like me to make a program that counts down from a settable time?
No, I want do different things..one will be an game elapsed timer, the other display, two scores, one teams on left of : and one on the right. Games only go to double digits. That may require 2 more buttons and another Arduino unless I can multiplex the control signals somehow, perhaps with a 4th button.
I'm by all means not an expert on the Arduino at all but do have some working programming knowledge. I would think if you instead used the button state to set a variable to 1 or 0 rather than pole the button directly you can put that in the clock loop to freeze the time if its been set. Id recommend just to Google 'Arduino stopwatch' as it should be right in line with what you want, IMO. Additionally, using shift registers would allow you to control several displays with just one Arduino. It will get more complicated if you nest registers but you can still do quite a bit. You should be able to, without it being too complicated get at least 2 7-segment digits per 1 shift register as long as you use the right one. And it would only require 2-3 pins on the Arduino for each one.
That would probably be a better way to program the button. I would have used shift registers, but I didn't have any on hand and it would require wiring them to transistors (pins used to select segment are negative). Maybe I'll buy the parts and make another version.
I found this display in a Knex kit, as well as multiple other parts. The kit is pretty cheap, and I reccomend getting it..........http://www.ebay.com/itm/KNEX-Electronic-Arcade-Pinball-Speedball-USED-Knex-Building-Set-/350585893648?pt=LH_DefaultDomain_0&amp;hash=item51a08c3310

About This Instructable




Bio: I love electronics, computers, and everything DIY!
More by Jimmacle:4-Digit 7-Segment LED Display + Arduino LEGO Mindstorms NXT: Roadster PSP-NX Supercharged My Bluetooth Range Extender 
Add instructable to: